Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 12 of 37

JANUS PSK for Basic, Version 2.1 Reference Manual, pages 111 to 120

Pages 111 to 120 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 111

imProtocolExtendedStatus – QuickBasic

2

Example '**************** imProtocolExtendedStatus ********* REM $INCLUDE: 'im20bas1.bi' 'Extend status protocol buffer DIM statusBuffer AS imCommStatusBufferS 'Initialize status buffer ' Note: Must assign StatusStrVersion as below to return proper ' status statusBuffer.StatusStructureVersion = CHR$(StatusStrVersion) statusBuffer.HandlerVer = STRING$(LEN(statusBuffer.HandlerVer), CHR$(0)) statusBuffer.HandlerType = 0 statusBuffer.Specific.BaudRate = 0 statusBuffer.Specific.Parity = CHR$(0) statusBuffer.Specific.StopBits = CHR$(0) statusBuffer.Specific.DataBits = CHR$(0) statusBuffer.Specific.ModemStatus = CHR$(0) statusBuffer.Specific.PortStatus = CHR$(0) statusBuffer.Specific.ActiveProt = 0 statusBuffer.Specific.LrcEnabled = CHR$(0) statusBuffer.Specific.IntercharDelay = 0 statusBuffer.Specific.TurnaroundDelay = 0 statusBuffer.Specific.ReceiveTimeout = 0 statusBuffer.Specific.TransmitTimeout = 0 statusBuffer.Specific.PolChar = CHR$(0) statusBuffer.Specific.SelChar = CHR$(0) statusBuffer.Specific.ResChar = CHR$(0) statusBuffer.Specific.reqChar = CHR$(0) statusBuffer.Specific.affChar = CHR$(0) statusBuffer.Specific.negChar = CHR$(0) statusBuffer.Specific.somChar = CHR$(0) statusBuffer.Specific.txeomLen = CHR$(0) statusBuffer.Specific.txeomChar1 = CHR$(0) statusBuffer.Specific.txeomChar2 = CHR$(0) statusBuffer.Specific.rxeomLen = CHR$(0) statusBuffer.Specific.rxeomChar1 = CHR$(0) statusBuffer.Specific.rxeomChar2 = CHR$(0) statusBuffer.Specific.flowCtrl = CHR$(0) statusBuffer.Specific.MultiDropAddr = CHR$(0) statusBuffer.Specific.MultiDropEnabled = CHR$(0) statusBuffer.Specific.EofLength = 0 statusBuffer.Specific.EofChar = CHR$(0) statusBuffer.Specific.HaveRecvClientBuffer = 0 statusBuffer.Specific.HaveXmitClientBuffer = 0 statusBuffer.Specific.ProtocolMode = 0 ' Call Intermec routine status% = imProtocolExtendedStatus(ImCom1, statusBuffer) ' Function call return status PRINT "Extd Prot Stat" PRINT HEX$(status%) temp$ = INPUT$(1) CLS LOCATE 1,1 ' Print first page of status info PRINT "Extd Status,Pg1of3" PRINT "Strut Ver = ", ASC(statusBuffer.StatusStructureVersion)

2-85

Page 112

imProtocolExtendedStatus – QuickBasic

PRINT "Hd Ver = ", statusBuffer.HandlerVer PRINT "Hd Type = ", statusBuffer.HandlerType PRINT "Baud = ", statusBuffer.Specific.BaudRate PRINT "Parity =", ASC(statusBuffer.Specific.Parity) PRINT "Stop =", ASC(statusBuffer.Specific.StopBits) PRINT "Data =", ASC(statusBuffer.Specific.DataBits) PRINT "Modem =", ASC(statusBuffer.Specific.ModemStatus) PRINT "Port stat = ", ASC(statusBuffer.Specific.PortStatus) PRINT "Ate prot = ", statusBuffer.Specific.ActiveProt PRINT "Lrc enble = ", ASC(statusBuffer.Specific.LrcEnabled) PRINT "Itc dely = ", statusBuffer.Specific.IntercharDelay PRINT "Trnd dely =", statusBuffer.Specific.TurnaroundDelay PRINT "RX tmeout = ",statusBuffer.Specific.ReceiveTimeout PRINT "Xt tmeout = ", statusBuffer.Specific.TransmitTimeout ' Pause between screens PRINT "Any key to cont'" temp$ = INPUT$(1) CLS LOCATE 1,1 PRINT "Extd Status,Pg2of3" ' Print third page of status info PRINT "Pol char = ", ASC(statusBuffer.Specific.PolChar) PRINT "Sel char = ", ASC(statusBuffer.Specific.SelChar) PRINT "Res char = ", ASC(statusBuffer.Specific.ResChar) PRINT "Req char = ", ASC(statusBuffer.Specific.reqChar) PRINT "Aff char = ", ASC(statusBuffer.Specific.affChar) PRINT "Neg char = ", ASC(statusBuffer.Specific.negChar) PRINT "Som char = ", ASC(statusBuffer.Specific.somChar) PRINT "Tx len = ", ASC(statusBuffer.Specific.txeomLen) PRINT "Txchar 1 = ", ASC(statusBuffer.Specific.txeomChar1) PRINT "Txchar 2 = ", ASC(statusBuffer.Specific.txeomChar2) PRINT "Rxlen = ", ASC(statusBuffer.Specific.rxeomLen) PRINT "Rxchar 1 = ", ASC(statusBuffer.Specific.rxeomChar1) PRINT "Rx char 2 = ", ASC(statusBuffer.Specific.rxeomChar2) PRINT "Flow ctrl = ", ASC(statusBuffer.Specific.flowCtrl) ' Pause between screens PRINT "Any key to cont'" temp$ = INPUT$(1) CLS LOCATE 1,1 PRINT "Extd Status,Pg3of3" ' Print second page of status info PRINT "Mul addr = ", ASC(statusBuffer.Specific.MultiDropAddr) PRINT "Mul enble = ", ASC(statusBuffer.Specific.MultiDropEnabled) PRINT "EOF len = ", statusBuffer.Specific.EofLength PRINT "EOF char = ", ASC(statusBuffer.Specific.EofChar) PRINT "Recv clt = ", statusBuffer.Specific.HaveRecvClientBuffer PRINT "Xmit clt = ", statusBuffer.Specific.HaveXmitClientBuffer PRINT "Prot mode = ", statusBuffer.Specific.ProtocolMode END

2-86

Page 113

imReceiveBuffer – QuickBasic

2 imReceiveBuffer Purpose:

This function receives the contents of a data buffer from a designated communications port.

Syntax:

REM $INCLUDE: 'im20bas1.bi' FUNCTION imReceiveBuffer% CDECL (BYVAL PortID AS INTEGER, BYVAL UserLength AS INTEGER, BYVAL DataBuffer AS INTEGER, BYVAL Timeout AS INTEGER, CommLength 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 UserLength parameter is the maximum number of bytes to receive and must be at least 256 bytes. The DataBuffer parameter is a far pointer to the array where you want to place the received data. This buffer must hold at least 256 bytes. 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 you select imInfiniteTimeout, the function will not return until the end of message character has been received.

2-87

Page 114

imReceiveBuffer – QuickBasic

OUT Parameters:

The CommLength is the actual number of bytes received upon completion of the call.

Return Value:

This function returns one of the standard status codes defined in Appendix A, “Status Codes.”

Notes:

This function does not return a parameter value until an end of message, a buffer is full, a timeout, or an error occurs. You must install a protocol handler to use this function.

See Also:

imReceiveBufferNoWait, imReceiveBufferNoprot, imCancelRxBuffer, imRxCheckStatus

Example '**************** imReceiveBuffer ****************** ' Note: You must have reader services and a communication protocol handler installed ' to enable send/receive buffer functions. ' Run these TSR's at DOS prompt before running these tests: ' rservice ' PHIMEC 1 ( 1 is COM1) Must be run with Phimec protocol REM $INCLUDE: 'im20bas1.bi' CONST buffsize = 300

' Data buffer must be at least 256 bytes

DIM str1 AS STRING * buffsize

' Fixed length strings of 300 bytes

DIM commLength AS INTEGER

' Actual length returned by imReceiveBuffer

PRINT "imReceiveBuffer" PRINT "Phimec protocol" PRINT "Default - 9600 E 7 1" ' Quit with <CR><LF> sequence PRINT "Ctrl JM to quit" PRINT "(<CR><LF>)" ' Init the string str1 = STRING$(buffsize, CHR$(0)) ' Call Intermec function status% = imReceiveBuffer(imCom1, LEN(str1), VARPTR(str1), 10000, commlength) ' Print results PRINT str1 ' Print return status(s) PRINT PRINT "Actual len = ", commlength PRINT "status = ", HEX$(status%) END

2-88

Page 115

imReceiveBufferNoprot – QuickBasic

2 imReceiveBufferNoprot Purpose:

This function receives a text string from the designated port without using the active protocol. Only the PHIMEC.EXE protocol handler supports this function, which is often used to receive a host initialization string before beginning transmission.

Syntax:

REM $INCLUDE: 'im20bas1.bi' FUNCTION imReceiveBufferNoprot% CDECL (BYVAL PortID AS INTEGER, BYVAL UserLength AS INTEGER, BYVAL DataBuffer AS INTEGER, BYVAL Timeout AS INTEGER, BYVAL EomChar AS INTEGER, CommLength 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 UserLength parameter is the maximum number of bytes you can receive and must be at least 256 bytes. The DataBuffer parameter is a far pointer to the data array where you want to place the received data. This buffer must hold at least 256 bytes. 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.

2-89

Page 116

imReceiveBufferNoprot – QuickBasic

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: 'im20bas1.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 AS INTEGER DIM eomChar AS INTEGER DIM done AS INTEGER 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>

2-90

Page 117

imReceiveBufferNoprot – QuickBasic

2

PRINT "Input chars" PRINT " Press Enter to end" ' Call the Intermec function status%= imReceiveBufferNoprot(ImCom1, buffsize, VARPTR(str3), 10000, eomChar, commLength) PRINT "Status = ", HEX$(status%) ' Print results PRINT str3 PRINT "Actual len", commLength ' Release resources status%= imCancelRxBuffer(ImCom1) END

2-91

Page 118

imReceiveBufferNoWait – QuickBasic 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: 'im20bas1.bi' FUNCTION imReceiveBufferNoWait% CDECL (BYVAL PortID AS INTEGER, SEG DataStruct AS imFarComDataStruct)

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 IM20BAS1.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.

2-92

Page 119

imReceiveBufferNoWait – QuickBasic

2

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: 'im20bas1.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 AS INTEGER ' 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, farcomBuffStruct)

2-93

Page 120

imReceiveBufferNoWait – QuickBasic

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

2-94