Re: serial port question.




And I was successfully able to send and recieve an unsigned character
array of 255 chars. (from 00 to FF) However, I was only able to do so
by sending and receiving one byte at a time. I have been unable to
accurately send and receive more then 6 - 7 bytes at one time

what do you mean when you say "I have been unable to accurately send and receive" ?

Are you receiving corruption or an error message?

here is a snippet of code which sets the serial port to
19200 8E1. where fd is the file descriptor for the open serial port.

int fd = open( "/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY );

struct termios options;

memset(&options, 0, sizeof( struct termios ) );

/* set baud rate to 19200 */
cfsetispeed(&options, B19200);
cfsetospeed(&options, B19200);

options.c_cflag |= (CLOCAL | CREAD);

options.c_cflag |= PARENB;
options.c_cflag &= ~PARODD; /* Even parity */
options.c_cflag &= ~CSTOPB; /* 1 Stop bit */
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8; /* 8 data bits */

options.c_cflag &= ~CRTSCTS;

options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

options.c_iflag |= (IGNPAR); /* Ignore parity */

options.c_iflag &= ~(IXON | IXOFF | IXANY);

tcsetattr(fd, TCSANOW, &options);

tcflush( fd, TCIOFLUSH );

you should then be able to just send and receive data by using the
commands.

write( fd, buffer, length );

bytes = read( fd, buffer, sizeof(buffer));

hope this helps :)
.



Relevant Pages

  • Re: help me with Comm filter in Numega
    ... into my local buffer and read MAX again till I have a total of 5. ... So how do you know the serial line is receiving any data from the remote ... >> Most likely you are you looking at the buffer before the serial port has ... >>> NTSTATUS CommFilterDevice::Write ...
    (microsoft.public.win32.programmer.kernel)
  • Re: pushing the envelope with sockets
    ... receiving on the socket they are received (upto the buffer size), you can even change what happens if the buffer runs full. ... int read = S.EndReceive; ... class AsyncReader: Reader ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fundamentals question, is this how it works?
    ... Note the packet may be partially received when you get ... That is what i thought i was saying that it receives it all in a stream ... receving the buffer size each time. ... receiving that many bytes i then break and wait for the next set of data ...
    (microsoft.public.win32.programmer.networks)
  • Re: CAsyncSocket and Send
    ... I'm also sending/receivingbinary data (file transfer). ... which usually is less than a full buffer). ... >> Are you using TCP/IP or UDP? ... >>>in C and the receiving side is MFC. ...
    (microsoft.public.vc.mfc)
  • Re: pushing the envelope with sockets
    ... so it would seem 2.0 does indeed buffer UDP. ... Using async I/O ... receiving on the socket they are received, ... Okay, so during *one* run, the cpu spent increases when input-data is ...
    (microsoft.public.dotnet.languages.csharp)