The text of a manual · part 27 of 37
JANUS PSK for Basic, Version 2.1 Reference Manual, pages 261 to 270
Pages 261 to 270 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 261
imReceiveBufferNoprot – Visual Basic
3
The Timeout parameter is a number or one of these constants: 0 to 32,767 ms 32,768 to 65,534 ms imZeroTimeout imInfiniteTimeout
Integer range See “Setting Timeout Values” in this chapter. No wait Wait forever
If imInfiniteTimeout is selected, the function will not return until the end of message character has been received. 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 character. OUT Parameters:
The CommLength parameter returns the actual number of bytes received.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
You must install the PHIMEC.EXE protocol handler to use this function. The difference between this function and imReceiveBufferNoWait is that when imReceiveBufferNoprot returns from the function call, the data has been read, the timeout has expired, or an error was encountered. When you call imReceiveBufferNoWait, program execution continues without checking for received data or errors.
See Also:
imReceiveBufferNoWait, imCancelRxBuffer, imRxCheckStatus
Example '**************** imReceiveBufferNoprot ************ REM $INCLUDE: 'im20vbas.bi' ' Data buffer size must be at least 256 bytes CONST buffsize = 300 ' Define fixed length strings of 300 bytes (256 is minimum string buffer) DIM str3 AS STRING * buffsize 'fixed length string ' Actual length returned by imReceiveBuffer DIM commLength DIM eomChar DIM done
3-95
Page 262
imReceiveBufferNoprot – Visual Basic
PRINT "imReceiveBufferNoprot" ' Get the receive environment ready status%= imCancelRxBuffer(ImCom1) ' Zero out string str3 = STRING$(buffsize, CHR$(0)) ' Define carriage return as end of message character eomChar = 13 '<CR> PRINT "Input chars" PRINT " Press Enter to end" ' Call the Intermec function status%= imReceiveBufferNoprot(ImCom1, buffsize, VARPTR(str3), VARSEG(str3), 10000, eomChar, VARPTR(commLength), VARSEG(commLength) PRINT "Status = ", HEX$(status%) ' Print results PRINT str3 PRINT "Actual len", commLength ' Release resources status%= imCancelRxBuffer(ImCom1) END
3-96
Page 263
imReceiveBufferNoWait – Visual Basic
3 imReceiveBufferNoWait Purpose:
This function receives data from the designated communications port and places the data into a user-defined record. It differs from imReceiveBuffer in that the programmer must set up the data record and monitor the transfer status until transmission is complete. This function runs in the background after it is initiated; no checks are made. Use this function when receiving multiple buffer transmissions in conjunction with imRxCheckStatus.
Syntax:
REM $INCLUDE: 'im20vbas.bi' FUNCTION imReceiveBufferNoWait% (PortID , VARPTR(DataStruct), VARSEG(DataStruct))
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 DataStruct parameter is a far pointer to the data array for the received data. This buffer must hold at least 256 bytes. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
You must build and maintain a DataStruct of the type imFarComDataStruct as described in IM20VBAS.BI. You must periodically check the protocolXferStatus element in the ImComDataBuffer record to see if all the data has been received. When protocolXferStatus is no longer code 8602H (communications port in use), all data is received. You must install a protocol handler to use this function.
3-97
Page 264
imReceiveBufferNoWait – Visual Basic
This function differs from imReceiveBufferNoprot in that program execution continues after imReceiveBufferNoWait is called. When imReceiveBufferNoprot returns from a function call, the data has been read, the timeout has expired, or an error was encountered. See Also:
imReceiveBufferNoprot, imCancelRxBuffer, imRxCheckStatus
Example '**************** imReceiveBufferNoWait ************ REM $INCLUDE: 'im20vbas.bi' ' Data buffer size must be at least 256 bytes CONST buffsize = 300 ' Data buffer structure for receive/transmit again and noprot DIM farcomBuffStruct AS imFarComDataStruct ' Extend status protocol buffer DIM statusBuffer AS imStatusBuffer ' Define fixed length strings of 300 bytes (256 is minimum string buffer) DIM str3 AS STRING * buffsize 'fixed length string DIM done ' The difference between imReceiveBufferNoWait and the imReceiveBufferNoprot ' is that the user must set up the imReceiveBufferNoWait comm ' struct and pend on the results. Whereas, in the Noprot receive, the ' user sets up the length of the buffer, points at that buffer and ' sends it off and returns. There is no pending on this level for the ' imReceiveBufferNoprot routine ' Phimec protocol handler must be installed to run this routine PRINT "imReceiveBufferNoWait" ' Get the receive environment ready status%= imCancelRxBuffer(imCom1) ' Zero out string str3 = STRING$(buffsize, CHR$(0)) ' Set up communication buffer structure farcomBuffStruct.command = imPhReceive farcomBuffStruct.protocolMode = imNoProtocol farcomBuffStruct.eomChar = CHR$(13) 'CR for terminating char farcomBuffStruct.userLength = buffsize farcomBuffStruct.SegDataPtr = VARSEG(str3) farcomBuffStruct.OffSetDataPtr = VARPTR(str3) farcomBuffStruct.protocolXferStatus = imCuInuse farcomBuffStruct.CommLength = 0 done = FALSE ' Call Intermec function status%= imReceiveBufferNoWait(ImCom1,
3-98
Page 265
imReceiveBufferNoWait – Visual Basic
3
VARPTR(farcomBuffStruct), VARSEG(farcomBuffStruct)) PRINT "Func1= ", HEX$(status%) ' Loop until first character in buffer is a 'Q' or Esc is pressed DO ' ' Check for receive errors: ' Print the error status IF status%= imIserror THEN PRINT "Rx Again err = ", HEX$(status%) done = FALSE ELSE ' Keyboard char temp$ = " " ' Get the receive data PRINT "Input chars" PRINT "Enter 'Q'" PRINT "or Esc to exit" ' Check to see if any characters are in buffer DO WHILE farcomBuffStruct.protocolXferStatus = imCuInuse AND temp$ <> CHR$(27) ' Pick up any keypad input temp$ = INKEY$ LOOP PRINT "Comm done" ' Print the input string PRINT str3 ' Update buffer for next block then call imRxCheckStatus to ' get protocol handler to reset status. farcomBuffStruct.command = imPhRecvAgain farcomBuffStruct.protocolXferStatus = imCuInuse farcomBuffStruct.commLength = 0 status%= imRxCheckStatus(ImCom1) END IF ' Quit if first char in buffer is a 'Q' or a 'q' ' or Esc has been pressed IF UCASE$(LEFT$(str3, 1)) = "Q" OR temp$ = CHR$(27) THEN done = TRUE ELSE ' Zero out string and loop str3 = STRING$(buffsize, CHR$(0)) ENDIF LOOP WHILE done = FALSE ' Release resources status%= imCancelRxBuffer(ImCom1) END
3-99
Page 266
imReceiveByte – Visual Basic 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: 'im20vbas.bi' FUNCTION imReceiveByte% (PortID, VARPTR(ReceiveByte ), VARSEG(ReceiveByte)
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:
3-100 imTransmitByte
Page 267
imReceiveByte – Visual Basic
3
Example '**************** imReceiveByte ******************** REM $INCLUDE: 'im20vbas.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), VARSEG(instring)) PRINT USING "!"; instring; keystr$ = INKEY$ ' Loop until Esc is pressed LOOP UNTIL keystr$ = CHR$(27) OR instring = CHR$(27) PRINT "status =
", HEX$(status%)
END
3-101
Page 268
imReceiveInput – Visual Basic 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: 'im20vbas.bi' FUNCTION imReceiveInput% ( Allowed , Timeout , VARPTR(Source), VARSEG(Source), VARPTR(Received$) VARSEG(Received$))
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 32,767 ms 32,768 to 65,534 ms imZeroTimeout imInfiniteTimeout
Integer range See “Setting Timeout Values” in this chapter. No wait Wait forever
If imInfiniteTimeout is selected, the function will not return until the end of message character has been received.
3-102
Page 269
imReceiveInput – Visual Basic
OUT Parameters:
3
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:
imGetLength, imGetLabelSymbology, imLinkComm
3-103
Page 270
imReceiveInput – Visual Basic
Example '**************** imReceiveInput ******************* ' $INCLUDE: 'im20vbas.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), VARSEG(comString), bufsize)
FOR I% = 1 TO 3 PRINT "Enter>>"; status% = imReceiveInput(ImAllSelect, imInfiniteTimeout, VARPTR(source%), VARSEG(source%), VARPTR(inString), VARSEG(inString)) PRINT ' Add a blank line IF source% = ImKeyboardSelect THEN PRINT "From Keypad" ELSEIF source% = imLabelSelect THEN PRINT "From Label" status% = imGetLabelSymbology (VARPTR(symbology%), VASEG(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
3-104