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

JANUS PSK for Ada Reference Manual, pages 121 to 130

Pages 121 to 130 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 121

im_power_status

3

The status_code parameter is a standard status code listed in Appendix A, “Status Codes.” Return Value:

None.

Example With System, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure powersta Is package SYSBYTE_IO is new INTEGER_IO (System.Byte); line_status : IM_LINE_STATUS; battery_status : IM_BATTERY_STATUS; backup_status : IM_BACKUP_STATUS; fuel_gauge : System.Byte; status : System.Word; in_char : Character := ' '; begin loop exit when in_char = 'q'; Put_Line("Checking power"); New_Line; im_power_status(line_status, battery_status, backup_status, fuel_gauge, status); if im_isgood (status) then Put_Line("Line Status: "); case line_status is when IM_ACline_NOT_CONNECTED => Put_Line("Not connected"); when IM_ACline_CONNECTED => Put_Line("Connected"); when IM_UNKNOWN_ACline => Put_Line("Unknown"); when others => Put_Line("Invalid"); end case; New_Line; Put_Line("Battery Status: "); case battery_status is when IM_HIGH_BAT => Put_Line("Charge high"); when IM_LOW_BAT => Put_Line("Charge low"); when IM_CRITICAL_BAT => Put_Line("Charge critical"); when IM_CHARGING_BAT => Put_Line("Charging battery");

3-81

Page 122

im_power_status when IM_UNKNOWN_BAT => Put_Line("Unknown"); when others => Put_Line("Invalid"); end case; New_Line; Put_Line("Backup Status: "); case backup_status is when IM_BACKUP_OK => Put_Line("Backup battery OK"); when IM_BACKUP_LOW => Put_Line("Backup battery low"); when others => Put_Line("Invalid"); end case; New_Line; Put("Fuel guage % "); case fuel_gauge is when 0..100 => SYSBYTE_IO.Put(fuel_gauge); when 255 => Put("Fuel gauge unknown"); when others => Put("Invalid"); end case; New_Line; Put("q to quit"); Get(in_char); else im_message (status); New_Line; end if; end loop; end powersta;

3-82

Page 123

im_protocol_extended_status

3 im_protocol_extended_status Purpose:

This function retrieves the protocol extended status from the designated communications port. You allocate the protocol status buffer or RF status buffer, and the protocol returns the status and setup in hexadecimal values.

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; function im_protocol_extended_status ( port : IN IM_COM_PORT, status_buffer : IN System.Address ) return 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 status_buffer parameter is the address of the record of type IM_COMM_STATUS_BUFFER_S for IM_COM1 and IM_COM2, or IM_COMM_STATUS_BUFFER_RF for IM_COM4. OUT Parameter:

None.

Return Value:

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

Notes:

You must set the element status_structure_version to IM_STATUS_STRUCT_VERSION before calling this function.

See Also:

im_receive_buffer_no_wait, im_transmit_buffer_no_wait

3-83

Page 124

im_protocol_extended_status

Example With System, Intrmecd_IO, Intrmecp_IO, Text_IO; Use System, Intrmecd_IO, Intrmecp_IO, Text_IO; procedure protstat Is package SYSBYTE_IO is new INTEGER_IO (System.Byte); package LONGINT_IO is new INTEGER_IO (Long_integer); package IM_PROTOCOL_ID_IO is new ENUMERATION_IO (enum => IM_PROTOCOL_ID); package IM_PROTO_MODE_ID is new ENUMERATION_IO (enum => IM_PROTO_MODE); package IM_PH_ID_IO is new ENUMERATION_IO (enum => IM_PH_ID); serial_status_buffer_ptr : System.Address; serial_buffer : IM_COMM_STATUS_BUFFER_S; status : System.Word; begin -- PHIMEC must be installed for this sample program to work correctly with COM1. serial_buffer.status_structure_version := IM_STATUS_STRUCT_VERSION; serial_buffer.handler_ver := " "; serial_status_buffer_ptr := serial_buffer'Address; status := im_protocol_extended_status (IM_COM1, serial_status_buffer_ptr); im_message (status); New_Line; Put ("Struct Ver:"); SYSBYTE_IO.Put (serial_buffer.status_structure_version); New_Line; Put("Handler ver: "); Put(serial_buffer.handler_ver); New_Line; Put("Type: "); IM_PH_ID_IO.Put(serial_buffer.handler_type); New_Line; Put("Baud: "); LONGINT_IO.Put(serial_buffer.sb.baud_rate, WIDTH => 6); New_Line; Put("Parity:"); SYSBYTE_IO.Put (serial_buffer.sb.parity); New_Line; Put("Stop bits:"); SYSBYTE_IO.Put (serial_buffer.sb.stop_bits); New_Line; Put("Data bits:"); SYSBYTE_IO.Put (serial_buffer.sb.data_bits); New_Line; Put("Act prot: "); IM_PROTOCOL_ID_IO.Put(serial_buffer.sb.active_prot); New_Line; end protstat;

3-84

Page 125

im_receive_buffer

3 im_receive_buffer Purpose:

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

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; procedure im_receive_buffer ( port : IN IM_COM_PORT; user_length : IN System.Word; buffer : IN System.Address; timeout : IN System.Word; 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 to be received and must be at least 256 bytes. The buffer parameter is the address of the string that will receive the data. The string 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

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

3-85

Page 126

im_receive_buffer

OUT Parameter:

The comm_length is the actual number of characters received upon completion of the call. The status_code parameter is a standard status code listed in Appendix A, “Status Codes.”

Return Value:

None.

Notes:

This procedure will not return a parameter value until it reaches the end of message, the buffer is full, or an error or timeout occurs. Do not link using the im_link_comm function for this procedure. You must install a protocol handler to use this function.

See Also:

im_receive_buffer_no_wait, im_receive_buffer_noprot, im_cancel_rx_buffer, im_rx_check_status

Example With System, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure rec_buff Is package SYSWORD_IO is new INTEGER_IO (System.Word); status comm_length data_buffer done length timeout

: System.Word; : System.Word; : String (1..300); : Boolean; : System.Word := 300; : System.Word;

begin -- Phimec protocol handler must be installed -- get the receive environment ready status := im_cancel_rx_buffer(IM_COM1); if im_iserror(status) then Put ("cancel rx error = "); im_message (status); New_Line; end if; -- clear the buffer data_buffer := (others=>Ascii.NUL); done := FALSE; Put_Line (" Rx/Tx Buffer"); Put_Line ("enter string and CR "); Put_Line ("at host"); Put_Line ("(q or Q to quit)");

3-86

Page 127

im_receive_buffer

3

-- call Intermec function timeout := 20000; -- 20 seconds im_receive_buffer (IM_COM1, length, data_buffer'Address, timeout, comm_length, status); if im_iserror(status) then Put ("rec buff error = "); im_message (status); New_Line; done := TRUE; end if; -- loop until first character in buffer is a 'Q' or 'q' while not done loop if im_issuccess(status) then for i in Integer range 1..Integer(comm_length) loop Put(data_buffer(i)); end loop; New_Line; Put ("comm_length is "); SYSWORD_IO.Put (comm_length, width => 3); New_Line; else Put ("Rx Again err = "); im_message (status); New_Line; done := TRUE; end if; --get the transmit environment ready status := im_cancel_tx_buffer(IM_COM1); if im_iserror(status) then Put ("canc tx1 status = "); im_message (status); New_Line; end if; status := im_transmit_buffer (IM_COM1, comm_length, data_buffer'Address, timeout); if im_iserror(status) then Put ("transmit buff err: "); im_message (status); New_Line; done := TRUE; end if; --get ready to receive again status := im_cancel_rx_buffer (IM_COM1); if im_iserror(status) then Put ("canc rx2 status = "); im_message (status); New_Line; end if; -- clear the buffer data_buffer := (others => Ascii.NUL); im_receive_buffer (IM_COM1, length, data_buffer'Address, timeout, comm_length, status); if im_iserror(status) then Put ("rec again status = "); im_message (status); New_Line; done := TRUE; end if;

3-87

Page 128

im_receive_buffer

-- 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 rec_buff;

3-88

Page 129

im_receive_buffer_no_wait

3 im_receive_buffer_no_wait Purpose:

This function receives a buffer of data as part of a record. It differs from im_receive_buffer 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. Use this function when receiving multiple buffer transmissions in conjunction with im_rx_check_status.

Syntax:

With Intrmecd_IO, Intrmecp_IO; Use Intrmecd_IO, Intrmecp_IO; function im_receive_buffer_no_wait ( port : IN IM_COM_PORT; data_struct : IN System.Address ) return 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 data_struct parameter is the address of the IM_COM_DATA_BUFFER record. OUT Parameter:

None.

Return Value:

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

Notes:

Build and maintain the IM_COM_DATA_BUFFER record as described in IM20ADAD.LIB. You must periodically check the protocol_xfer_status element in the IM_COM_DATA_BUFFER record to see if all the data has been received. When protocol_xfer_status is no longer code 8602H (communications port in use), all data is received. You must install a protocol handler to use this function.

3-89

Page 130

im_receive_buffer_no_wait

This procedure will not work if linked. This procedure differs from im_receive_buffer_noprot in that program execution continues after im_receive_buffer_no_wait is called. See Also:

im_receive_buffer_noprot, im_cancel_rx_buffer, im_rx_check_status, im_receive_buffer_no_wait

Example With System, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure exnowait is package SYSWORD_IO is new INTEGER_IO (System.Word); COMM_INUSE : constant System.Word := 16#8602#; -- Comm port in use com_buff_rec : IM_COM_DATA_BUFFER; --data record for rec/xmit status : System.Word; data_buffer : String (1..300); done : Boolean := FALSE; begin -- Phimec protocol handler must be installed to run this routine. New_Line(2); Put_Line(" JANUS 2010"); Put_Line("Rx/Tx Buffer No Wait"); New_Line; -- get the receive environment ready status := im_cancel_rx_buffer(IM_COM1); if im_iserror(status) then Put ("canc rx1 = "); im_message (status); New_Line; end if; Put_Line("Ready to receive"); Put_Line("q to quit"); New_Line; --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 -- call Intermec function status := im_receive_buffer_no_wait (IM_COM1, com_buff_rec'Address); if im_iserror(status) then Put ("rec buff = "); im_message (status);

3-90