Hi:
I've been playing with serial ports on my Powerbook G3 and I discovered some not so nice actions in class SerialPort. If the port is in use elsewhere, trying to open it gets a Primitive Error.
I'd rather have my code get back some indication that the port didn't open, so I made some small mods to SerialPort, which are attached. Basically, primitives used during open answer nil if they fail, and the open method answers nil also.
Dave
_______________________________ David N. Smith IBM T J Watson Research Center Hawthorne, NY _______________________________ Any opinions or recommendations herein are those of the author and not of his employer.
Hi, I too am now playing with serial ports, both on my Mac at home and on a Windows 2000 machine at work...not having a whole lot of luck so far although I have managed on W2000 when the ports are connected by a null modem cable, to read on com2 what I've sent out on com1. So far am unable to similarly read from an external device. Can you give me any tips? Especially on my Mac as that is what I'm working on at the moment. Which is port 1 on Mac, the modem or the printer? Port 1 seems to open ok, but port 2 gives a primitive failed error. I see that your change set appears to be in the image (3.1Alpha4332).
What I'm basically attempting to do at work is continuously read from an external device, splitting into different streams (displayed on separate windows) depending on a character received with the high bit set. eg if I receive a char hex 80, the following chars will get displayed on one window until an different char eg hex 81 gets received wherupon the following chars will get displayed on a second window. The intent is to be able to differentiate which part of the program, different debug statements are coming from via one port on an instrument. Thx for any and all help. Ken
At 20:04 -0400 on 2000/06/27, David N. Smith (IBM) is rumored to have written:
Hi:
I've been playing with serial ports on my Powerbook G3 and I discovered some not so nice actions in class SerialPort. If the port is in use elsewhere, trying to open it gets a Primitive Error.
I'd rather have my code get back some indication that the port didn't open, so I made some small mods to SerialPort, which are attached. Basically, primitives used during open answer nil if they fail, and the open method answers nil also.
Dave Attachment converted: hd7600:SerialPortChanges.1.cs (TEXT/R*ch) (0001AA45) _______________________________ David N. Smith IBM T J Watson Research Center Hawthorne, NY _______________________________ Any opinions or recommendations herein are those of the author and not of his employer.
On Sunday 09 September 2001 04:46 pm, Ken G. Brown wrote:
Hi, I too am now playing with serial ports, both on my Mac at home and on a Windows 2000 machine at work...not having a whole lot of luck so far although I have managed on W2000 when the ports are connected by a null modem cable, to read on com2 what I've sent out on com1. So far am unable to similarly read from an external device.
On the Mac, you may have to re-boot with AppleTalk not using the modem/serial port for things to work (per Mark Guzdial).
Well, note first that you have to set up the serial port parameters before you open the port.
Second, make sure that your handshaking is set up right. And that your cables are connected OK. And that your external device does the right thing with handshaking.
Also note that the serial port read is NON BLOCKING. So pay attention to your return values, especially to the number of characters read. You may well get no characters. Be sure to use a Delay when polling the serial port so that you don't starve other Processes.
I've posted here before helping people with their serial problems; perhaps a search of the list archives would help.
Ken:
Doing some MIDI?
If you have a builtin modem, it can hold one serial port. I was able to use the serial code to dial a phone number and give various AT commands. Other than that I haven't used it.
Dave
At 17:46 -0600 9/9/01, Ken G. Brown wrote:
Hi, I too am now playing with serial ports, both on my Mac at home and on a Windows 2000 machine at work...not having a whole lot of luck so far although I have managed on W2000 when the ports are connected by a null modem cable, to read on com2 what I've sent out on com1. So far am unable to similarly read from an external device. Can you give me any tips? Especially on my Mac as that is what I'm working on at the moment. Which is port 1 on Mac, the modem or the printer? Port 1 seems to open ok, but port 2 gives a primitive failed error. I see that your change set appears to be in the image (3.1Alpha4332).
What I'm basically attempting to do at work is continuously read from an external device, splitting into different streams (displayed on separate windows) depending on a character received with the high bit set. eg if I receive a char hex 80, the following chars will get displayed on one window until an different char eg hex 81 gets received wherupon the following chars will get displayed on a second window. The intent is to be able to differentiate which part of the program, different debug statements are coming from via one port on an instrument. Thx for any and all help. Ken
At 20:04 -0400 on 2000/06/27, David N. Smith (IBM) is rumored to have written:
Hi:
I've been playing with serial ports on my Powerbook G3 and I discovered some not so nice actions in class SerialPort. If the port is in use elsewhere, trying to open it gets a Primitive Error.
I'd rather have my code get back some indication that the port didn't open, so I made some small mods to SerialPort, which are attached. Basically, primitives used during open answer nil if they fail, and the open method answers nil also.
Dave Attachment converted: hd7600:SerialPortChanges.1.cs (TEXT/R*ch) (0001AA45) _______________________________ David N. Smith IBM T J Watson Research Center Hawthorne, NY _______________________________ Any opinions or recommendations herein are those of the author and not of his employer.
squeak-dev@lists.squeakfoundation.org