Programming :: Get Data From Serial Port Function Read() Blocks When Data Not Available?

Jun 11, 2009

I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:

//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;

[code]...

View 1 Replies


ADVERTISEMENT

Networking :: Serial Port : Read Data, Not Reading Complete Data?

Mar 5, 2010

I have an application where I am sending data via serial port from PC1 (Java App) and reading that data in PC2 (C++ App). The problem that I am facing is that my PC2 (C++ App) is not able to read complete data sent by PC1 i.e. from my PC1 I am sending 190 bytes but PC2 is able to read close to 140 bytes though I am trying to read in a loop.Below is code snippet of my C++ AppOpen the connection to serial port

Code:
serialfd = open( serialPortName.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
if (serialfd == -1)

[code]...

View 5 Replies View Related

Programming :: Read Some Data From Controller Using Serial Port?

Aug 25, 2010

i want to try with a small application in linu in that i want to read some data from controller using serial port and i wanna transfor that data to another meachin in the network for this i want serial port interfacing programming as well as socket programming.

View 1 Replies View Related

Programming :: Serial Port Data Read Time Interval?

Oct 30, 2010

I am writing a C program which reads data over serial port. While reading data, if I send my data(which is a 13 byte structure) periodic with a period of 1 second for 10 times I read it without problem and I read the data 10 times as I sent and as I expectBut if I send data continuousuly(without any time interval between each sending) 10 times I can only read 1 of them(I can only read it once).

View 11 Replies View Related

Programming :: Debian Serial Port Read() Return Wrong Data?

Jul 6, 2010

I am implementing a simple serial protocol where my ARM9 board, running Linux is communicating to a slave peripheral board. The Master sends a 12 byte data stream and the peripheral board returns status in a 23 byte response. The serial port is opened in raw mode. It works perfectly on 44 reads; however, on the 45 read the data returned from the read() is incorrect. I've framed what's being sent on an oscope and it is correct.The coincidence is that 23 x 44 = 1012. It's as though the receive buffer is 1K and when I go past the boundary I get bad data. The read following the bad one is good again.I've tried flushing the buffer before reading but get the same result.Here's the port initialization code:

Code:
int initport(int fd)
{

[code]...

View 4 Replies View Related

Programming :: Intercept Data On Serial Port?

Dec 21, 2010

I dont know if this is the right forum, But I try to find a solution, I want to intercept data from/to serial port without disrupting the software that manages the serial port, (I would like to save the data to a file or sent into a socket) I searched somes modules and programs (linspy, ttysniff, interceptty, maxty ...), A bit complicated (There are some diff. between kernel 2.4 and 2.6), So I'd like to change the serial port driver to intercept the "read" and "write " and do what I want with the data, I'd like to know what do you think about

View 3 Replies View Related

Programming :: Send Data Through Serial Port Using C?

Oct 20, 2009

I am not a profession programmer. I have to write a C code which send some command to attach display using C program. Can any one please help me in this regard.

View 3 Replies View Related

Programming :: Displaying I/O Possible When Reading Data From The Serial Port?

Aug 31, 2009

I have got a problem while reading from the serial port. I'm working on iMX-31 board and Eclipse IDE. Whenever I'm trying to read any data through the serial port, it's displaying I/O Possible and the application is being terminated. After reading I'm trying to write this data on a file. Here are the excerpts from the code:

# int main()
{
if (openport()<0)

[code]...

View 7 Replies View Related

Programming :: Serial Port Program Not Outputting The Right Data?

Apr 11, 2009

I have connected a device to my linux system with a serial cable (rs232). The settings are: port /dev/ttyS0, baud rate=38400, data bits=8, stop bits=1, no parity, no hardware or software handshaking. I wrote a linux program that sends 1 byte to the device, but the device doesn't receive it. I know the serial ports are working because when I use the CuteCOM application to send data, the device DOES receive it, so obviously it is a problem with my code..

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[code].....

View 2 Replies View Related

Programming :: Send /receive Data Through Serial Port In Fedora?

Dec 27, 2010

I am doing work on serial port. I want to send/receive data to/from Microcontrolar through serial port. But I don't know how to initialize, receive and send data to Serial port. i am new in fedora so i hav'nt any deep concept of fedora.can anyone send me C code , which communicate through serial port in fedora (or atleast help me). I am using Fedora 11.

View 6 Replies View Related

Programming :: Write Data To Text File Which Is Coming On Serial Port Infintely?

Aug 5, 2010

trying read serial COM port and want to write that received data to file, now its writing only one sentence, but i want to write full file which coming on serial port, as i'm sending file from hyper terminal and reading on linux pc, If i put while loop its not writing anything,without while loop its writing only one line and if send big file then application terminates and then writes to file.But i need do write any size which coming on serial port.Finally i want write full file which is coming on hyper terminal, after writing the file it has wait for next data. This is my code,

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

[code]...

View 9 Replies View Related

Programming :: Serial Port Communication Program Always Lose One Byte Data: 0x00?

Dec 13, 2009

I wrote a serial port communication program to access a equipment.

int main(void)
{
int fd = 0;
int nread = 0,i = 0,nwrite = 0, tmpread = 0, m = 0, n = 0 ;

[code]....

View 2 Replies View Related

Programming :: Data Directory In Automake - Data Is Always Read-only ?

May 9, 2010

I have some data files that should be distributed with my program. Using dist_pkgdata_DATA in Makefile.am, I get these files installed to /usr/local/data/share/package-name. The problem is that data is read-only, and my program needs to modify it. Playing with dist_sharedstate_DATA, dist_localstate_DATA, dist-data_DATA varibles, I got different installation directories, like /usr/local/com, usr/local/var, but data is always read-only.

How can I distribute modifiable data files with my package? I need some common directory for all users, or maybe local data in a user directory.

View 1 Replies View Related

Networking :: Serial Port : Not Able To Write Big Chunk Of Data?

Mar 10, 2010

I am trying to send text data from one PC to other using Serial cable. One of the PC is running linux and I am sending data from it using write(2) system call. The log size is approx 65K bytes but the write(2) system call returns some 4K bytes (i.e. this much amount of data is getting transferred). I tried breaking the data in chunks of 4K but write(2) returns -1.My question is that "Is there any buffer limit for writing data on serial port? or can I send data of any size?. Also do I need to continously read data from other PC as I write 4K chunk of data"Do I need to do any special configuration in termios structure for sending (huge) data?

View 4 Replies View Related

Programming :: Passing Data From Interrupt Handler Function To Tasklet Function?

May 18, 2010

I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.

View 2 Replies View Related

Software :: In Platform \ Use Ioctl Function To Read/write Data To Hid Device?

Jun 24, 2011

Now i have a problem.I want to used a hid usb device under linux 2.6.11.But i can't know how to used ioctl function to send and receive data to a hid device

View 3 Replies View Related

Programming :: Read X Bytes From Serial Port?

May 5, 2010

I am trying to write some code that interfaces with an AVR over a serial port. Basically I send a command then read the output which is 6 bytes. I need to receive all 6 bytes before the program continues. Is there a way to do this? If I use read() it returns -1 unless I add a delay before reading the port. Is there a way to get it to read the 6 bytes as soon as they arrive?In python you simply say how many bytes you want and the max time you are willing to wait which seems a whole lot easier than read

View 1 Replies View Related

Programming :: Read Datas After Write On Serial Port?

Mar 8, 2011

I'm currently developping a C program to drive a Telit GM862-GPS module using the serial port of an embedded board (SBC9261).The communication with the module is based on AT commands : I just send my command to the module, through the RS232 line, and the module answers immediately.Here's an example with a basic command returning the GPS's acquired position, sent with Minicom :

Code:
AT$GPSACP
$GPSACP: 104323.000,4x45.6171N,00x38.6219E,0.8,446.5,3,272.14,0.21,0.11,080311,09

[code]...

View 4 Replies View Related

Software :: Serial Printer Setup 7 Data Bits Rx 8 Data Bits Tx

Aug 8, 2010

About 7 years ago I setup a Redhat system with 8 serial terminals and 8 serial printers, this is still running but I need to get another system running so the original can be taken down for maintenance. The printers are ancient Newbury data dot matrix wide carriage with 7 data bits receive 8 data bits transmit Xon/Xoff flow control. Now I remember setting the transmit and receive data bits as above but after 7 years can't remember where.

View 2 Replies View Related

Programming :: Read Data From A Socket?

Aug 24, 2010

I need to read data from a socket but it should be always listening because data arrives continuously .. I thought something like this would do it but it doesn't work .... I already set the socket options before

Code: char databuf[1024];
int datalen = sizeof(databuf);
if(read(sd, databuf, datalen) < 0)
{

[Code]....

View 9 Replies View Related

Programming :: Possible To Open A Symlink (won't Follow) And Read Data From It?

Nov 9, 2010

I try to use open(2) system call, and I find one relevant flag: O_NOFOLLOW. But it will only return -1 rather than the symlink's file descriptor

View 5 Replies View Related

Programming :: Read Unknown Data Length From Usb Pipe?

Aug 12, 2010

I've written a usb device driver and a program that sends and receives data over the bulk pipe. The read function sometimes returnsI'm reading an unknown amount of data. However, using a usb tracker I can see that the correct data is being sent.The error only occurs sometimes.I expect that the read function is told to read more data that it receives it would fail and return -1, however if this was the case then every read call would fail.

View 4 Replies View Related

Software :: Receiving UDP Multicast - Blocks As If There Is No Data

Nov 6, 2010

I am trying to port some MS Visual Studio C++ code to Linux/wxWidgets. The code is socket-based and very similar between Windows and Linux. In Linux the socket, bind, and setsocketopt all return with no error. See:

Code:
BOOL CAV15Input::SetupSocket(BOOL Out)
{ if(pU->PrDebug) {
sprintf(_send,"CAV15Input::SetupSocket for port %d",pSonar->dPort);
pU->OutMsg(_send,1,0); } pSonar->UDP_Sock=0; pSonar->UDPError=0;
pSonar->UDP_Sock=socket(AF_INET,SOCK_DGRAM,0);
if(pSonar->UDP_Sock<0 ) {
pU->OutMsg("socket failed on SetupSocket",11,0);
pSonar->UDP_Sock=0;
pSonar->UDPError|=4;
return FALSE; }
// the AF_INET address family, which contains IP addresses,
local.sin_family=AF_INET;
local.sin_addr.s_addr=inet_addr(pSonar->IP_Add_PC);
local.sin_port=htons(pSonar->dPort);
// from Dave Goffe:
//> int t = 1;
//>
//>setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&t,sizeof(t));
int t=1; if(setsockopt(pSonar->UDP_Sock,
SOL_SOCKET, SO_REUSEADDR,
(char *)&t,sizeof(t)) <0) {
CloseSock();
pU->OutMsg("set SO_REUSEADDR failed in SetupSocket",11,0);
pSonar->UDPError|=4;
return FALSE; }
if(bind(pSonar->UDP_Sock,(sockaddr *)&local,sizeof(local)))
{ CloseSock();
pU->OutMsg("bind failed in SetupSocket",11,0);
pSonar->UDPError|=8; return FALSE; }
if(pU->PrDebug) {
sprintf(_send,"socket setup & bind OK for port %d",pSonar->dPort);
pU->OutMsg(_send,1,0); }
// Join multicast group
if(pSonar->datatype) // for element data
mreq.imr_multiaddr.s_addr=inet_addr(pSonar->IP_Add_ELD);
else // for beam data
mreq.imr_multiaddr.s_addr=inet_addr(pSonar->IP_Add_HRB);
mreq.imr_interface.s_addr=inet_addr(pSonar->IP_Add_PC);
if(setsockopt(pSonar->UDP_Sock,
IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *)&mreq,sizeof(mreq)) <0) {
CloseSock();
pU->OutMsg("join multicast failed in SetupSocket",11,0);
pSonar->UDPError|=16;
return FALSE;
} if(pU->PrDebug) {
if(pSonar->datatype) // for element data
sprintf(_send,"join multicast OK on %s",pSonar->IP_Add_ELD);
else // for beam data
sprintf(_send,"join multicast OK on %s",pSonar->IP_Add_HRB);
pU->OutMsg(_send,1,0); }
jMCast=1; return TRUE; }

But then when I try
recv(pSonar->UDP_Sock,&pUDP->u_dg_cM.cM[8],reedlen,0);
it blocks as if there is no data. (In Windows this works fine.) Is there something else in Linux and/or wxWidgets that I'm missing that could prevent UDP datagrams from being received? Is there some way in Linux to monitor incoming UDP traffic?

View 2 Replies View Related

Ubuntu :: Unable To Read The Serial Port

May 23, 2010

I am using a F232 USB to serial adapter for connecting my wireless modem to my laptop and I wrote a simple C code for reading data received by the modem transmitted by another modem installed on my target device.The problem is my code is simply giving 0.00000 (float data) output .When I use the same code with my desktop its running fine and I am getting relevant data.What may be the problem? I even changed the permission for my /dev/ttyUSB0 I am using Ubuntu 10.04 on both my laptop and desktop

below is my code

Code:

#include <stdlib.h>
#include <math.h>
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

[code]....

View 5 Replies View Related

Ubuntu :: Serial Port Read, Write After DTR Toggle In C++?

Mar 31, 2011

I need to read and write to a serial device. When I connect via gtkterm, I need to toggle DTR before I can communicate with the device . My problem is that I cannot emulate this in C++.

I want to write some code that can setup a comport, toggle the DTR, then read and write strings to the port. However all my attempts have been fruitless. My serial settings are B9600, No parity, no hardware control, 8 bt characters and 1 stop bit:

Code:
#include <iostream>
#include <SerialStream.h>
#include <sys/ioctl.h>
#include <fcntl.h>
using namespace LibSerial;

[Code]...

View 1 Replies View Related

General :: Serial Port Configuration - Write Or Read

Dec 1, 2010

I have a minilinux that I being working on, the problem now is that the serial ports doesn't seem to work (I have 4 serial ports).They don't write or read.

I run the command setserial g /dev/ttySx and it says that his IRQ are 3 or 4 (3 for ttyS0 and ttyS2 , 4 for ttyS1 and ttyS4)�but when I run the command: dmesg | grep ttyS the IRQ�s are 0 for ALL my serial ports� could be this the reason why my serial ports aren�t working right??? And if it is how can I solve the problem??

View 2 Replies View Related

General :: Serial And Parallel Data Communication On Fedora 13

Apr 22, 2010

I have been trying out serial and parallel data communication on Fedora 13 Beta. I can easily see the list of serial ports through:

Code:
setserial -g /dev/ttyS[0-3]
And can also write some data through:
Code:
ll > /dev/ttyS0
But I am unable to see parallel ports
I can see something like:
Code:
/dev/parport0
But when I try out:
ll > /dev/parport0
It throws error.

View 3 Replies View Related

Programming :: Convert The String Data Type To Other Primitive Data Type?

Mar 4, 2011

I am trying to generic way to convert the string datatype to other primitive data type. To achieve, i used Template . But i getting error and couldn't resolve the issue and error reported is also clueless.

Code
====
#include <vector>
#include <iostream>
#include <string>

[Code].....

View 7 Replies View Related

General :: Redirecting Serial Data To An External Devices Using Bluetooth?

Apr 24, 2010

i have the following challenge: i have a Bluetooth GPS device that i have connected to my linux notebook. but now i also want to use the same device (or better, GPS data stream) for my Navigation device (HP Ipaq with TomTom). make an serial port bluetooth service (sending) that my Navigation device can connect to. copy the incoming bluetooth serial port data stream to the outgoing bluetooth serial port.

i have already installed GPSD so i have the TCP port where the GPS data is available for everything on my notebook. but now i also want it to send it out through bluetooth.

1. is there someone out there who already did this?

2. how to make an bluetooth serial port service on Fedora 12?

3. how to copy a data stream from 1 device to the next device?

View 1 Replies View Related

General :: Minicom Shows Offline And Is Not Capturing The Serial Data Being Sent?

Jan 5, 2011

Minicom was running fine two days ago capturing data from a gage device via a serial cable. Yesterday, users of the data started complaining that they were not receiving any data.

The minicom status line reads offline. Is this part of the problem or is this normal (I never really noticed it before.) All settings on the gage device match the minicom settings.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved