Page 1 of 1

Serial Port Question

Posted: Sun Dec 20, 2015 10:55 pm
by Vernon
SerialClose(1);
fdserial = OpenSerial(1, 9600, 1 ,8, eParityNone);
SerialClose(0);
ffserial = OpenSerial(0, 115200, 1 ,8, eParityNone);

ReplaceStdio( 0, ffserial ); // stdin
ReplaceStdio( 1, fdserial ); // stdout
ReplaceStdio( 2, ffserial ); // stderr

I have the above. Is it possible to read from a port when it is not the stdio?

Thanks!

Re: Serial Port Question

Posted: Mon Dec 21, 2015 12:11 pm
by rnixon
Absolutely. I think the normal mode for any type of data port is to read/write directly. I only use stdio for debugging in release mode or status messages on a debug serial port.

Re: Serial Port Question

Posted: Tue Dec 22, 2015 12:49 pm
by sblair
Yes you can read/write to any serial port that you have opened an fd to regardless of the stdio settings. I use multiple serial ports all the time.

Scott

Re: Serial Port Question

Posted: Wed Dec 23, 2015 6:37 am
by pbreed
functions are read
and write

read the header file

nburn\include\iosys.h



int read(int fd ,char * buf, int maxlen);
Where fd is the fd gotten from the serial open...
reads what is availible and returns.
If no data is availible it blocks until it gets at least one charactor...

If you need timeouts..
int ReadWithTimeout( int fd, char *buf, int nbytes, unsigned long timeout );


int write(int fd, const char * buf, int len);