Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSCOMM INPUT STRING

Status
Not open for further replies.

prustie

Programmer
Aug 6, 2001
34
GB
Hi

I am trying to access the status of a receipt printer through MSCOMM using the following code:

mscomm.portopen=true
mscomm.output=chr(29)+chr(114)+chr(1)
do while mscomm.buffercount=0
enddo
lstatus=mscomm.input
mscomm.portopen=false

This returns one character into lstatus but I cannot figure out what to do with it. lstatus has a TYPE() of U.

Any suggestions?

Malcolm P


 
Malcolm,
Do you have #DEFINES or contants that set values for "true" and "false"?

Try mscomm.InBufferCount instead. "lstatus" should actually hold the character string in the input buffer (not status), so right now you have nothing in it!

Rick
 
Rick

Thanks for your reply.

You are right it is inbuffercount that is just a typo.

Not sure what you mean about lstatus.

When the receipt printer receives the .output code it should return 1 byte of data each bit of which relates to certain settings on the printer. I seem to be getting 1 byte into lstatus but cannot do anything with it.

Malcolm.
 
Malcolm

It is probably a low ascii character that doesn't have a corresponding character to it and that is why you are getting a U from the Type() function. The easiest way I would try is to mimick the types of things that printer would do to see what the value is of the character in the input buffer. You can do this by simply using the asc() function to return the value of it and look up what that value is on the ascii list.

Example:
mscomm.portopen=true
mscomm.output=chr(29)+chr(114)+chr(1)
do while mscomm.inbuffercount=0
enddo
lstatus = mscomm.input
mscomm.portopen = .F.
do case
case asc(lstatus) = 1
*do code
case asc(lstatus) = 2
*do code
endcase

what ever is displayed is the value of the input buffer
Then you can write a simple case struture that tests for the different ascii values of lstatus.

Hope this helps, if not I'll try to help more

Dave Long
 
Dave

Thanks

I can now read lstatus and in fact can now tell whether the till drawer attached to the receipt printer is open or shut which was the main object of the exercise.

Malcolm P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top