How to talk to a modem through a com port

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to talk to a modem through a com port

Louis LaBrunda
Hi Guys,

I want to talk to a telephone model through a com port.  I am able to write and read data with code like this:

 | deviceFile buffer rc readCount |

 deviceFile := CfsFileDescriptor
   open: 'COM3'
   oflag: ORDWR
   share: ODENYNONE.

 deviceFile inspect.

 buffer := 'ATZ', Cr asString.
 rc := deviceFile write: buffer startingAt: 1 nbyte: buffer size.
 rc isCfsError ifTrue: [CwMessagePrompter errorMessage: 'Error writing'].

 buffer := String new: 100.
 readCount := deviceFile read: buffer startingAt: 1 nbyte: 7.

 readCount inspect.    "Contains the number of characters read from the port"
 buffer inspect. "Contains readCount number of characters in positions 1 through readCount"
 deviceFile close. "close the port"


The problem is that if I try to read more than the number of bytes the modem is returning VA Smalltalk goes into what appears to be a loop that I can't break into with the panic button.  I have to kill the whole running VA Smalltalk.

I think (but can't prove or remember for sure) that this use to work.  That reading (asking for) say 100 bytes would answer with the number of bytes available.  This is the behavior I want.  It make sense that the read would work this way as it returns the number of bytes read, which if it waited for all bytes asked for were read, would always answer the number asked for which is useless.

Could there be some other flag or open code I should be using?  Should I be telling the VM something to get it not to wait for all the data?  Any help is appreciated.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.