Can I use newlisp's read to read serial data for sure?

Started by dexter, December 22, 2013, 03:10:23 AM

Previous topic - Next topic

dexter

I use stty to config serial port,this part is ok as far as we know



Then I use newlisp's read function (read) to read the data from serial port



most of the time,it's ok ,the data was ok and right



just a few chance, it'll  get the wrong,short data, seems lost or mixed parts of



so wired



after a long time until now,I have a question, Can I really use newlisp's read to read serial port??



I doubt it myself now, I dont think linux can not handle a serial communication.

TedWalther

It should work; are the read's timing out?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

dexter

No timeout ,i just set it to wait the data forever to read

TedWalther

Are you reading a byte at a time?  And what settings are you using on the tty?  What happens if you "tail -f" the tty device?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

dexter


root@OpenWrt:~# stty -F /dev/ttyUSB0
speed 38400 baud; line = 0;
min = 150; time = 1;
ignbrk -brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok noflsh -echoctl -echoke


Not reading a byte from serial, I read a lot of data from serial port

for example



I read

a0 ec fc 00 00 e5 c8 a0 b0 19 00 00 e5 c8 a0 fc 7f 00 00 e5 c8

the data above is ok

now this below

a8 ec fc 00 a8 b0 19 a8 fc 7f

Now the right data will be  

a8 ec fc 00 a8 b0 19 00 a8 fc 7f 00


two "00" lost ,I dont know why, the data is shortter than "0xa0" data, right?



and I use the same way to send data from my chip 8051 to openwrt

some times , it will be  a8 ec fc 00 a8 b0 19 00 a8 fc 7f, only one "00" lost



I am so confused , because of 0xa8 is different to 0xa0? I use 0xa0,0xa8 to be the head flag of my data.

dexter

I finally got this issue



if my device send 0x11 to openwrt , newlisp can not read it; 0x12 is ok ,0x01 is ok ,so else ,I could not test them all



That's why it lost data ,because the lost data is 0x11....





So wired problem...

TedWalther

Quote from: "dexter"So wired problem...


Sorry, did you mean "wierd" problem, or rather, problem with the wiring of your device?  And does the data correctly show up when you run "tail -f /dev/ttyS0" ?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

fred

0x11 is the code for XON Resume transmission, could it be "eaten" as a flow control character?

I do not know stty but perhaps something like -ixon  -ixoff or raw mode?

dexter

yeah

After I send my last reply

I know 0x11 0x13 0x0d is some CODE



now it seems working now,thanks all :)