Dear programmers,
I'm working on a program that connects a FDTI device in Linux. I open the connection with:
Then I send data with:Code:PRS485 = fopen("/dev/ttyUSB0", "r+");
I read information with:Code:fwrite (output , 1 , 9, PRS485);
I've 2 LED's on the FTDI chip: 1 on the receive and 1 on the send data/Code:fread(input, 1, 9, PRS485);
The problem was:
1. The code keeps sending, but never makes it to reading.
I searched on Internet to a clue, and found out that a litle pause between fwrite and fread should fix this problem. So I putted a simple wait for loop in it.
The problem now is:
2. Somethimes it does not receive al the data, then the whole code Stops, couse fread expects more bytes or a \n.
How can I stop fread after a amounth of time?
Kind regards,
Libpgeak



1Likes
LinkBack URL
About LinkBacks



