On 11/2/02 10:06 AM, "Ted Spencer" <tedspencer@...> wrote: >> From the nimble fingers of Heather Donahue (maclists@...) (2/11/02 > 9:54 AM) came... > >> portData = _"B" >> WRITE# portNum, portData >> PRINT "sent: ";portData >> PRINT "echo: "; >> >> amtData = LOF(portNum, 1) >> LONG IF amtData >> FOR i = 1 TO amtData >> READ# portNum, portData >> PRINT portData, >> NEXT >> END IF > > Unless this LONG IF is in something that gets called repeatedly, or, at > least, after a substantial (since your little BASIC micro will be VERY slow > in G3/G4 terms) delay, it will not pick up THIS response until you're > expecting to see the NEXT response. > > How about something like: > > portdata = "" // a single character from the serial port > portdatasum = "" // the built-up string > DO > read # portnum, portdata;0 // which will get something if it's there > if portdata then portdatasum = portdatasum + portdata > UNTIL portData = _properdelimiter I gave that a try with negative results. No matter how long I waited, the port didn't return any additional bytes. I tried using the UNIX read & write calls directly, after using FB's Open function, and have gotten closer to getting it to work. A snippet looks like this: // send B and expect echo and 2's comp portDataWrite = _"B" portDataRead = 0 PRINT "sent: ";portDataWrite // send "B" to port amtDataWrite = FN Write( fileDescriptor, @portDataWrite, 1 ) // receive echo of "B" amtDataRead = FN Read( fileDescriptor, @portDataRead, 1 ) PRINT "echo: ";portDataRead PRINT "response: "; // get response from device (-66) DO amtDataRead = FN Read( fileDescriptor, @portDataRead, 1 ) IF ( portDataRead != 0 ) THEN PRINT portDataRead, portDataRead = 0 UNTIL ( amtDataRead == 0 ) If I run through this code a few times, including the reset procedure, it would eventually (almost) respond with the proper data. Then I changed my code around to read and write to my modem port. I got the same poor results. After sending 'ATZ' I got no response, until I sent it again. Then I got an 'ATZ\rOK\r' I'm going to incorporate the Apple SerialSample code that R.P. mentioned into a new project to try and initialize the modem port. If I can get that to work properly I'll introduce that code into my Stamp Editor code. Since the SerialSample is tested code (and compiles and works fine under Project Builder) it shouldn't be to difficult to port to BASIC. Although, maybe I should try and modify the C code first to see if it will work with the Stamp Device.