The text of a manual · part 13 of 37
JANUS PSK for Basic, Version 2.1 Reference Manual, pages 121 to 130
Pages 121 to 130 of 362
The original document is the PDF (601 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Intermec J2020, Intermec J2010 and Intermec J2050
Page 121
imReceiveByte – QuickBasic
2 imReceiveByte Purpose:
This function receives one byte of data through the designated communications port. This function is identical to MS-DOS INT 14H service 02H.
Syntax:
REM $INCLUDE: 'im20bas1.bi' FUNCTION imReceiveByte% CDECL (BYVAL PortID AS INTEGER, ReceiveByte AS INTEGER)
IN Parameters:
The PortID parameter identifies the communications port as follows: imCom1 imCom2 imCom4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
OUT Parameters:
The ReceiveByte parameter is a pointer to the byte received from the communications port.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
This function requires the PC standard protocol handler PHPCSTD.EXE. If you are using PHIMEC.EXE and want to receive a single byte, use imReceiveBuffer with a buffer length of one instead of the imReceiveByte function.
See Also:
imTransmitByte
2-95
Page 122
imReceiveByte – QuickBasic
Example '**************** imReceiveByte ******************** REM $INCLUDE: 'im20bas1.bi' DIM instring AS STRING * 1 PRINT "imReceiveByte" ' If the Mode command is used, DO NOT install the Phpcstd protocol ' If the Phpcstd protocol is installed DO NOT use the Mode commmand ' Set up comm port SHELL "MODE COM1:9600 E 7 1" ' Init JANUS keyboard key press buffer keystr$ = "" PRINT "Press Esc to exit" ' Get COM1 input and print to screen DO ' Call Intermec function status% = imReceiveByte (imCom1, VARPTR(instring)) PRINT USING "!"; instring; keystr$ = INKEY$ ' Loop until Esc is pressed LOOP UNTIL keystr$ = CHR$(27) OR instring = CHR$(27) PRINT "status = END
2-96
", HEX$(status%)
Page 123
imReceiveInput – QuickBasic
2 imReceiveInput Purpose:
This function gets input from the source and places it into the received buffer. You can use the imGetLength function after this function to get the input length.
Syntax:
REM $INCLUDE: 'im20bas1.bi' FUNCTION imReceiveInput% CDECL (BYVAL Allowed AS INTEGER, BYVAL Timeout AS LONG, Source AS INTEGER, (SADD (Received$)) AS INTEGER)
IN Parameters:
The Allowed parameter defines the available input source and is one or more of these constants: imLabelSelect imKeyboardSelect imCom1Select imCom2Select imCom4Select imAllSelect
Label selected Keypad selected COM1 selected COM2, scanner port selected (2010 and 2050) COM4 selected (RF only) All sources are selected
The Timeout parameter is the receive timeout period. You can exit the function before data is received or before the timeout occurs by performing an application break sequence (see your JANUS user’s manual). The return status indicates whether the function was successful, a timeout occurred, or the application break was received. The Timeout parameter is a number or one of these constants: 0 to 65,534 ms imZeroTimeout imInfiniteTimeout
Numeric range No wait Wait forever
If imInfiniteTimeout is selected, the function will not return until the end of message character has been received.
2-97
Page 124
imReceiveInput – QuickBasic
OUT Parameters:
The Source parameter specifies the actual input source and is one of these constants: imNoSelect imLabelSelect imKeyboardSelect imCom1Select imCom2Select imCom4Select
No selection made Label selected Keypad selected COM1 selected COM2, scanner port selected (2010 and 2050) COM4 selected (RF only)
The Received parameter is the variable where the data is placed. Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
If input from more than one source is received before this function is called, the first available input is returned in this order: label, keypad, COM1, COM2, and COM4. If you are using a communications port, you must install a protocol handler and call imLinkComm. You must install the Reader Wedge to use this function. For information on loading RWTSR.EXE, see “Runtime Requirements” earlier in this chapter.
See Also:
2-98 imGetLength, imGetLabelSymbology, imLinkComm
Page 125
imReceiveInput – QuickBasic
2
Example '**************** imReceiveInput ******************* ' $INCLUDE: 'im20bas1.bi' CONST bufsize = 300 DIM inString AS STRING * bufsize DIM comString AS STRING * bufsize CLS
' Clear the screen imSetInputMode(imProgrammer) ImLinkCom% = imLinkComm(imCom1, VARPTR(comString), bufsize) FOR I% = 1 TO 3 PRINT "Enter>>"; status% = imReceiveInput(ImAllSelect,imInfiniteTimeout,source%,VARPTR(inString)) PRINT ' Add a blank line IF source% = ImKeyboardSelect THEN PRINT "From Keypad" ELSEIF source% = imLabelSelect THEN PRINT "From Label" status% = imGetLabelSymbology(symbology%) IF symbology% = imCode39 THEN PRINT "Code 39" ELSE PRINT "Another code" ENDIF ELSEIF source% = imCom1Select THEN PRINT "From Serial" ELSE PRINT "Unknown source" END IF ' Get length of received data length% = imGetLength(source%) ' Print data received. If the string is printed without doing the ' LEFT$, the entire 300 byte fixed-length string will be printed. PRINT "Recvd>>";LEFT$(inString,length%) NEXT I% ImLinkCom% = imUnlinkComm(imCom1) imSetInputMode(ImWedge)
END
2-99
Page 126
imRsInstalled – QuickBasic imRsInstalled Purpose:
This function determines whether or not the reader services (RSERVICE.EXE) program is installed.
Syntax:
REM $INCLUDE: 'im20bas1.bi' FUNCTION imRsInstalled% CDECL ()
IN Parameters:
None.
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Example '**************** imRsInstalled ******************** REM $INCLUDE: 'im20bas1.bi' ' Call the Intermec function status% = imRsInstalled PRINT "status = ", HEX$(status%) IF status% = imRsAllSuccess THEN PRINT "Rservice installed ELSE PRINT "Rservice not installed" END IF END
2-100
Page 127
imRxCheckStatus – QuickBasic
2 imRxCheckStatus Purpose:
This function directs the active protocol handler to check the communications port buffer status variable to determine if the application program has accepted the previous data. Use this function with the imReceiveBufferNoWait function to receive multiple buffers.
Syntax:
REM $INCLUDE: 'im20bas1.bi' FUNCTION imRxCheckStatus% CDECL (BYVAL PortID AS INTEGER)
IN Parameters:
The PortID parameter identifies the communications port as follows: imCom1 imCom2 imCom4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
You must install a protocol handler to use this function.
See Also:
imReceiveBufferNoWait
Example See example for imReceiveBufferNoWait.
2-101
Page 128
imSerialProtocolControl – QuickBasic imSerialProtocolControl Purpose:
This function controls the protocol mode for a designated communications port and determines whether the receive mode is with or without protocol according to the input parameter. Any change clears the input buffer and resets the reader command parser. Use this function to set protocol when connected to a communications port. The return value indicates a success if the port is currently linked to the Virtual Wedge. If the port is not currently linked to the Virtual Wedge, the function returns an error.
Syntax:
REM $INCLUDE: 'im20bas1.bi' FUNCTION imSerialProtocolControl% CDECL (BYVAL PortID AS INTEGER, BYVAL ProtocolSwitch AS INTEGER, BYVAL EomChar AS INTEGER)
IN Parameters:
The PortID parameter identifies the communications port as follows: imCom1 imCom2 imCom4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
The ProtocolSwitch parameter affects how incoming messages are received and is one of these constants: imNoChange imProtocolOff imProtocolOn imNewTermChar
Keep the current protocol Turn the protocol OFF Turn the protocol ON Use the new termination character
The ProtocolSwitch affects all incoming messages as follows: • If imNoChange is specified, the protocol and end of message settings remain the same as the last time the function was called. • If imProtocolOff is specified, the incoming message is terminated with the specified end of message character. If the end of message character is null, the function terminates upon receiving the first character.
2-102
Page 129
imSerialProtocolControl – QuickBasic
2
• If imProtocolOn is specified, the incoming message is terminated with the end of message character of the active protocol. • If imNewTermChar is specified, imProtocolOff is assumed and the new end of message character specified in the parameter list is used. The EomChar parameter is the end of message character needed to terminate input from the communications port. The character is normally a carriage return, but you can set it to any other character. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
Requires imLinkComm. The receive buffers are cleared whenever the protocol is turned ON or OFF. To change the termination character (or to not change the setting at all), use imNewTermChar or imNoChange instead of toggling the protocol.
See Also:
imLinkComm
2-103
Page 130
imSerialProtocolControl – QuickBasic
Example '**************** imSerialProtocolControl ********** REM $INCLUDE: 'im20bas1.bi' CLS DIM linkBuffer AS STRING * 300 DIM inputBuffer AS STRING * 300 DIM eomChar AS INTEGER eomChar = 13 timeout% = 10000 source% = 0 linkBuffer = STRING$(300, CHR$(0)) inputBuffer = STRING$(300, CHR$(0)) CALL imSetInputMode(imProgrammer) status% = imLinkComm(imCom1, VARPTR(linkBuffer), LEN(linkBuffer)) ' Turn on the protocol status% = imSerialProtocolControl(imCom1, imProtocolOn, eomChar) ' Get data from com 1 PRINT "Waiting for data" WHILE source% <> 1 inputBuffer = STRING$(300, CHR$(0)) status% = imReceiveInput(imCom1Select, timeout%, source%, VARPTR(inputBuffer)) WEND PRINT "Message is:" PRINT inputBuffer status% = imUnLinkComm(imCom1) CALL imSetInputMode(imWedge) PRINT "Press any key" temp$ = INPUT$(1) END
2-104