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 14 of 25

JANUS PSK for Ada Reference Manual, pages 131 to 140

Pages 131 to 140 of 250

The original document is the PDF (415 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 131

im_receive_buffer_no_wait

3

New_Line; end if; -- loop until first character in buffer is a 'Q' or 'q' while not done loop if im_issuccess(status) then -- get the receive data while (com_buff_rec.protocol_xfer_status = COMM_INUSE) loop null; end loop; Put_Line ("Receive done"); status := im_rx_check_status (IM_COM1); if im_iserror(status) then Put ("rx check = "); im_message (status); New_Line; end if; Put ("comm_length is "); SYSWORD_IO.Put (com_buff_rec.comm_length, width => 3); New_Line; for i in Integer range 1..Integer(com_buff_rec.comm_length) loop Put(data_buffer(i)); end loop; New_Line; else Put ("Rx no wait err = "); im_message (status); New_Line; end if; com_buff_rec.command := IM_CU_TRANSMIT; com_buff_rec.protocol_xfer_status := COMM_INUSE; com_buff_rec.user_length := com_buff_rec.comm_length; com_buff_rec.comm_length := 0; com_buff_rec.data_ptr := data_buffer'Address; com_buff_rec.protocol_mode := IM_NO_PROTOCOL; com_buff_rec.eom_char := 0; status := im_transmit_buffer_no_wait (IM_COM1, com_buff_rec'Address); if im_issuccess (status) then while (com_buff_rec.protocol_xfer_status = COMM_INUSE) loop Put_Line ("sending data"); end loop; Put_Line ("Buffer sent"); status := im_tx_check_status (IM_COM1); if im_iserror(status) then Put ("tx check = "); im_message (status); New_Line; end if; else Put ("transmit stat = "); im_message (status); New_Line; end if; New_Line; -- set up to receive again status := im_cancel_rx_buffer (IM_COM1); if im_iserror(status) then Put ("canc rx2 = ");

3-91

Page 132

im_receive_buffer_no_wait im_message (status); New_Line; end if; --fill the comm buffer structure com_buff_rec.command := IM_CU_RECEIVE; com_buff_rec.protocol_xfer_status := COMM_INUSE; com_buff_rec.user_length := System.Word (data_buffer'Length); com_buff_rec.comm_length := 0; com_buff_rec.data_ptr := data_buffer'Address; com_buff_rec.protocol_mode := IM_NO_PROTOCOL; com_buff_rec.eom_char := 16#0d#; -- CR for terminating char status := im_receive_buffer_no_wait(IM_COM1, com_buff_rec'Address); if im_iserror(status) then Put ("rec no wait = "); im_message (status); New_Line; end if; -- quit if first char in buffer is a 'Q' or a 'q' if ((data_buffer(1) = 'Q') or (data_buffer(1) = 'q')) then done := TRUE; end if; end loop; status := im_cancel_rx_buffer (IM_COM1); if im_iserror(status) then Put ("canc rx last = "); im_message (status); New_Line; end if; status := im_cancel_tx_buffer (IM_COM1); if im_iserror(status) then Put ("canc tx last = "); im_message (status); New_Line; end if; end exnowait;

3-92

Page 133

im_receive_buffer_noprot

3 im_receive_buffer_noprot Purpose:

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

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; procedure im_receive_buffer_noprot ( port : IN IM_COM_PORT; user_length : IN System.Word; buffer : IN System.Address; timeout : IN System.Word; term_char : IN Character; comm_length : OUT System.Word; status_code : OUT System.Word);

IN Parameter:

The port parameter identifies the communications port as follows: IM_COM1 IM_COM2 IM_COM4

COM1. COM2, scanner (2010 and 2050) COM4 (RF only)

The user_length parameter is the maximum number of characters you can receive and must be at least 256 bytes. The buffer parameter is the address of the buffer that will receive the data. The buffer’s length must be 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 numeric range for timeout is from 1 to 65,534 ms. You can also use one of the following constants: IM_ZERO_TIMEOUT IM_INFINITE_TIMEOUT

No wait Wait forever

3-93

Page 134

im_receive_buffer_noprot

If IM_INFINITE_TIMEOUT is selected, the function will not return until the end of message character has been received. The term_char 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 Parameter:

The comm_length parameter retrieves the actual number of characters received. The status_code parameter is one of the standard status codes defined in Appendix A, “Status Codes.”

Return Value:

None.

Notes:

You must install the PHIMEC.EXE protocol handler. This procedure will not work if linked. The difference between this procedure and im_receive_buffer_no_wait is that when im_receive_buffer_noprot returns from the procedure call, the data has been read, the timeout has expired, or an error was encountered.

See Also:

im_receive_buffer_no_wait, im_cancel_rx_buffer

Example With System, Intrmecd_IO, Intrmecp_IO, Text_IO; Use System, Intrmecd_IO, Intrmecp_IO, Text_IO; procedure exnoprot Is package SYSWORD_IO is new INTEGER_IO (System.Word); status : System.Word; comm_length : System.Word := 0; timeout : System.Word := 20000; -- 20 seconds eom_char : System.Byte := 16#0D#; -- CR for terminating char RX_data_buffer : String (1..300) := (others => Ascii.NUL); TX_data_buffer : String (1..300) := (others => Ascii.NUL); RX_buff_length : System.Word := System.Word(RX_data_buffer'Length); TX_buff_length : System.Word; RX_data_ptr : System.Address := RX_data_buffer'Address; TX_data_ptr : System.Address := TX_data_buffer'Address; done : Boolean := FALSE;

3-94

Page 135

im_receive_buffer_noprot

3 begin -- Phimec protocol handler must be installed to run this routine New_Line(2); Put_Line(" Janus 2010 "); Put_Line("Rx/Tx Buffer No Prot"); New_Line; -- get the receive environment ready status := im_cancel_rx_buffer(IM_COM1); if (im_iserror(status)) then Put ("canc rx1 error = "); im_message (status); New_Line; end if; -- Clear the transmission buffer status := im_cancel_tx_buffer (IM_COM1); Put_Line("Ready to receive"); Put_Line("q to quit..."); New_Line; -- call Intermec function im_receive_buffer_noprot (IM_COM1, RX_Buff_length, RX_data_ptr, IM_INFINITE_TIMEOUT, eom_char, comm_length, status); -- loop until first character in buffer is a 'q' while not done loop if im_isgood(status) then Put_Line ("Receive done"); -- Display number of characters received Put ("comm_length is "); SYSWORD_IO.Put (comm_length, width => 3); New_Line; -- Display buffer contents for i in Integer range 1..Integer(comm_length) loop Put(RX_data_buffer(i)); end loop; New_Line; else Put_Line ("Rx no protocol err = "); im_message (status); New_Line; -- Since there was an error, clear the receive buffer and -- reset the comm port status := im_cancel_rx_buffer (IM_COM1); end if; -- copy RX_ to TX_ for i in Integer range 1..Integer(comm_length) loop TX_data_buffer (i) := RX_data_buffer (i); end loop; TX_buff_length := comm_length + 1; TX_data_buffer(Integer(TX_buff_length)) := Ascii.CR; status := im_transmit_buffer_noprot (IM_COM1, TX_buff_length, TX_data_ptr, timeout); if im_isgood (status) then Put_Line ("Buffer transmitted");

3-95

Page 136

im_receive_buffer_noprot else Put_Line ("tx status = "); im_message (status); New_Line; -- Since there was an error in the transmission, clear the buffer -- and reset the comm port status := im_cancel_tx_buffer (IM_COM1); end if; New_Line; -- call Intermec receive function im_receive_buffer_noprot (IM_COM1, RX_Buff_length, RX_data_ptr, IM_INFINITE_TIMEOUT, eom_char, comm_length, status); -- quit if first char in buffer is a 'Q' or a 'q' if ((RX_data_buffer(1) = 'Q') or (RX_data_buffer(1) = 'q')) then done := TRUE; end if; end loop; -- Clear buffers and reset comm port status := im_cancel_rx_buffer (IM_COM1); status := im_cancel_tx_buffer (IM_COM1); end exnoprot;

3-96

Page 137

im_receive_byte

3 im_receive_byte Purpose:

This procedure receives one byte of data through the designated communications port. This procedure is identical to MS-DOS INT 14H service 02H.

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; procedure im_receive_byte ( port : IN IM_COM_PORT; receive_byte : OUT Character; status_code : OUT System.Word);

IN Parameter:

The port parameter identifies the communications port as follows: IM_COM1 IM_COM2 IM_COM4

OUT Parameter:

COM1 COM2, scanner (2010 and 2050) COM4 (RF only)

The receive_byte parameter is the byte read from the communications port. The status_code parameter is a standard status code listed in Appendix A, “Status Codes.”

Return Value:

None.

Notes:

This procedure requires the PC standard protocol handler, PHPCSTD.EXE. If you are using PHIMEC.EXE and want to receive a single byte, use im_receive_buffer with a buffer length of one instead of the im_receive_byte procedure. This procedure will not work if linked.

See Also:

im_transmit_byte

3-97

Page 138

im_receive_byte

Example With System, DosCall, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, DosCall, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure recbyte Is status : System.Word; RX_byte : Character := ' '; eom_char : Character; setup_comm_status : Integer; function setup_com (port : System.Word) return Integer Is -- This function sets up the communications port for RS232, -- 9600 baud, even parity, 7-bit words, and 1 stop bit using -- a DosCall procedure. RS232 : Constant Integer := 16#14#; B9600 : Constant System.Word := 16#E0#; EVEN : Constant System.Word := 16#18#; WORD7 : Constant System.Word := 16#02#; STOP1 : Constant System.Word := 16#00#; Regs : DosCall.Simple_Regs; setup : System.Word; begin setup := 0; if ((port /= 0) and (port /= 1)) then return -1; end if; setup := B9600 + WORD7 + EVEN + STOP1; Regs.AX := setup; Regs.DX := port; DosCall.Simple_Int_Call (RS232, Regs); return 0; -- Good return end setup_com; --************************* main program starts here ***************** begin -- Phimec protocol handler must NOT be installed to run this routine -- get the comm environment ready setup_comm_status := setup_com(0); if setup_comm_status = 0 then eom_char := Ascii.CR; Put_Line("Enter characters at"); Put_Line("terminal"); Put_Line("<CR> to end"); RX_byte := Ascii.NUL; loop -- Receive and display bytes until <CR> is sent im_receive_byte (IM_COM1, RX_byte, status); exit when RX_byte = eom_char; if (im_issuccess(status)) then if RX_byte in ' '..'~' then Put(RX_byte); else Put_Line("Unprintable char"); end if;

3-98

Page 139

im_receive_byte

3 else Put ("rec byte status = "); im_message (status); New_Line; end if; end loop; New_Line; Put_Line ("Receive done"); else Put_Line("Com setup failed"); im_message (System.Word(setup_comm_status)); New_Line; end if; end recbyte;

3-99

Page 140

im_receive_input im_receive_input Purpose:

This procedure retreives input from the source and places it into the receive buffer. You can use the im_get_length function after this procedure to get the input length.

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; procedure im_receive_input ( allowed_source : IN IM_ORIGIN; timeout : IN System.Word; returned_source : OUT IM_ORIGIN; ret_string : OUT String; status_code : OUT System.Word);

IN Parameter:

The allowed_source parameter defines the available input source and is one or more of the following constants: IM_LABEL_SELECT IM_KEYBOARD_SELECT IM_COM1_SELECT IM_COM2_SELECT IM_COM4_SELECT IM_ALL_SELECT

Label selected Keypad selected COM1 selected COM2, scanner (2010 and 2050) COM4 selected (RF only) All 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 numeric range for timeout is from 1 to 65,534 ms. You can also use one of the following constants: IM_ZERO_TIMEOUT IM_INFINITE_TIMEOUT

No wait Wait forever

If IM_INFINITE_TIMEOUT is selected, the function will not return until the end of message character has been received.

3-100