>>I am trying to read a serial port after sending a command to a device. >> The problem is that it works most of the times, but >>every 5th, or 10th, or 20th read (it varies), I get extraneous characters, >>first couple of characters missed, or just plain jibberish. >>characAvail=LOF(thePort,1) >>LONG IF characAvail >> characToRead=characAvail >> IF characToRead>255 then characToRead=255 >> READ FILE thePort,@x$+1, characToRead >> POKE@x$,characToRead >>END IF >I am using FB^3. My cable is good as I get the same results from all of >them. It is wired as RS-422. Variables are long integer. I neglected to >state that I send out a command first and try to retrieve an answer from the >device. I discovered that if I force a deleay of 20 or so, the reads start >to work. It could be a hand-shaking problem. If you really are getting wrong ASCII characters that were not sent by the device, the problem must be at a lower level than the code snippet that you posted. Your device may be sending characters without waiting for the proper acknowledgment from the Mac's serial port. Missing characters, on the other hand, could be due either to faulty handshaking or to a bug in the part of your program that makes use of the x$ string: low-level serial stuff --> the code snippet --> do something with x$ Can you show us more of your code, including setting up the port (the OPEN "C" statement and the HANDSHAKE statement)? The Mac port and the external device obviously must have exactly the same settings for handshaking, baud rate, parity, stop bits and wordlength. If your device can be configured, it's worth trying different settings, especially for HANDSHAKE. >Also, can you elaborate on why you can't dim strings less than 255 bytes? I just meant that your code assumes that x$ is DIMmed at 255 bytes. What is the total length of the answer from the device, and what buffer size is set by your OPEN "C" statement? Robert P.