miller@unicom.UUCP (Gregory S Miller) (10/12/89)
Sci. Comp. Ctr., College of Marin, Kentfield CA Science Computer Center, COM, Kentfield CA College of Marin; SCC, Kentfield CA Keywords: I was given the job of writing plotter program for the HP 7475A. I must convert a database to the corresponding HPGL commands and write them to the serial port. I use 9600 baud, 8 bits, 1 stop, and no parity; the plotter is set likewise. Obviously handshaking is in order. Though the plotter supports four types of handshaking, I used ENQ/ACK. I checked the appendix and provided the right setup info using non handskaking I/O. The program is written in Turbo C vers 2.0. I used the bioscom() function to read, write, and check the serial port since I could easily do I/O with COM2 aswell (stdaux defaults to COM1 and cannot be redirected). Problem: After following the algorithm in the appendix, I still get errors sending - the computer times out. My algorithm goes like this: [In the following steps, BLK represents the number of bytes I ENQ the plotter for. BLK == 256 at the start. 256 is the block size I setup the plotter with] [a] prepare string to send [b] if (BLK-strlen(string to send)) > 0 goto [c] else [d] [c] I send out one byte after another stopping ONLY when NULL is reached in the string. BLK-=strlen(string to send). I do not pause or wait for anything while sending chars. goto [a] [d] I send out the ENQ character followed by the output trigger. Now I wait for input from the plotter [e] the plotter turns off the receive buffer since FULL Duplex on CPU ... time passes until plotter has at least 256 bytes in buffer ... [f] the plotter outputs the ACK character followed by the output terminator. [g] I send the echo terminator, telling the plotter to turn on the receive buffer. [h] reset BLK to 256. goto to [c]. I've told the HP to put in a 5 m.s. inter-char delay and to wait 250 m.s after receiving output trigger before responding to ENQ. I've never seemed to get a clean return of the ACK+output terminator. I had to force the program to get them, and get them in order using not so elegant code... I wonder why I can't get them nicely. My computer times out sometimes especially when plotting arcs. What's wrong???? Now that I've written the question, the only bug I see is that in the SPECIAL case when BLK is exactly exhausted, I have not left enough buffer space (1 byte shy) to send another ENQ char. Anything else? Also, when waiting to receive from the serial port, what bits must be hi or low before actually fetching a byte? Borland, in an example for the bioscom() function, suggests bit anding the status value with 0x100 (data ready high) when reading AND writing data BEFORE ACTUALLY reading/writing a byte. What about sending data? I would much prefer watching line 20 of the serial port. However, the status info does not return the status of pin 20, or does it? God, a lot of questions I know - but I really am deep in this and ... Thanks for any help!
miller@unicom.UUCP (Gregory S Miller) (10/12/89)
Sci. Comp. Ctr., College of Marin, Kentfield CA Science Computer Center, COM, Kentfield CA College of Marin; SCC, Kentfield CA Keywords: I was given the job of writing plotter program for the HP 7475A. I must convert a database to the corresponding HPGL commands and write them to the serial port. I use 9600 baud, 8 bits, 1 stop, and no parity; the plotter is set likewise. Obviously handshaking is in order. Though the plotter supports four types of handshaking, I used ENQ/ACK. I checked the appendix and provided the right setup info using non handskaking I/O. The program is written in Turbo C vers 2.0. I used the bioscom() function to read, write, and check the serial port since I could easily do I/O with COM2 aswell (stdaux defaults to COM1 and cannot be redirected). Problem: After following the algorithm in the appendix, I still get errors sending - the computer times out. My algorithm goes like this: [In the following steps, BLK represents the number of bytes I ENQ the plotter for. BLK == 256 at the start. 256 is the block size I setup the plotter with] [a] prepare string to send [b] if (BLK-strlen(string to send)) > 0 goto [c] else [d] [c] I send out one byte after another stopping ONLY when NULL is reached in the string. BLK-=strlen(string to send). I do not pause or wait for anything while sending chars. goto [a] [d] I send out the ENQ character followed by the output trigger. Now I wait for input from the plotter [e] the plotter turns off the receive buffer since FULL Duplex on CPU ... time passes until plotter has at least 256 bytes in buffer ... [f] the plotter outputs the ACK character followed by the output terminator. [g] I send the echo terminator, telling the plotter to turn on the receive buffer. [h] reset BLK to 256. goto to [c]. I've told the HP to put in a 5 m.s. inter-char delay and to wait 250 m.s after receiving output trigger before responding to ENQ. I've never seemed to get a clean return of the ACK+output terminator. I had to force the program to get them, and get them in order using not so elegant code... I wonder why I can't get them nicely. My computer times out sometimes especially when plotting arcs. What's wrong???? Now that I've written the question, the only bug I see is that in the SPECIAL case when BLK is exactly exhausted, I have not left enough buffer space (1 byte shy) to send another ENQ char. Anything else? Also, when waiting to receive from the serial port, what bits must be hi or low before actually fetching a byte? Borland, in an example for the bioscom() function, suggests bit anding the status value with 0x100 (data ready high) when reading AND writing data BEFORE ACTUALLY reading/writing a byte. What about sending data? I would much prefer watching line 20 of the serial port. However, the status info does not return the status of pin 20, or does it? God, a lot of questions I know - but I really am deep in this and ... Thanks for any help!