The text of a manual · part 24 of 25
JANUS PSK for Ada Reference Manual, pages 231 to 240
Pages 231 to 240 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 231
B Appendix B: Ada Programs
Page 232
Page 233
DISPMODE.ADA
B
This appendix contains the Ada sample programs from your PSK Language Libraries disk.
DISPMODE.ADA -- File Name: dispmode.ada --- Purpose: This sample program demonstrates how to change the display -mode of the reader. It uses Intermec’s Ada procedure -im_get_display_mode to get the current display size mode, -video mode, scroll mode, and character height, then displays -each parameter on the screen. It also calls Intermec’s Ada -function im_set_display_mode to change the display mode -to use double height characters and resets to normal -display mode before exiting. --- COPYRIGHT (c) 1994 INTERMEC CORPORATION, ALL RIGHTS RESERVED With System, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure dispmode Is package IM_STD_SIZE_MODE_IO is new ENUMERATION_IO (enum => IM_STD_SIZE_MODE); package IM_STD_VIDEO_MODE_IO is new ENUMERATION_IO (enum => IM_STD_VIDEO_MODE); package IM_SCROLL_MODE_IO is new ENUMERATION_IO (enum => IM_SCROLL_MODE); package IM_CHARACTER_HEIGHT_IO is new ENUMERATION_IO (enum => IM_CHARACTER_HEIGHT); status : System.Word; size : IM_STD_SIZE_MODE; video : IM_STD_VIDEO_MODE; scroll : IM_SCROLL_MODE; char_ht : IM_CHARACTER_HEIGHT; inchar : Character := ' '; begin -- RWTSR must be installed before running this program Put_Line ("Getting disp mode"); New_Line; im_get_display_mode (size, video, scroll, char_ht, status); if im_iserror(status) then Put_Line ("Get Disp Mode error:"); im_message(status); New_Line; else Put ("size : "); IM_STD_SIZE_MODE_IO.Put (size); New_Line;
B-3
Page 234
DISPMODE.ADA
Put ("video : "); IM_STD_VIDEO_MODE_IO.Put (video); New_Line; Put ("scroll : "); IM_SCROLL_MODE_IO.Put (scroll); New_Line; Put ("char_ht : "); IM_CHARACTER_HEIGHT_IO.Put (char_ht); New_Line; end if; New_Line; Put_Line("Setting disp mode"); Put_Line("Any key to continue"); Get(inchar); status := im_set_display_mode (IM_SIZE_MODE_80X25, IM_STD_VIDEO_MODE_0, IM_LCD_SCROLL_AT_25, IM_DOUBLE_CHAR_HEIGHT); if im_isgood(status) then im_get_display_mode (size, video, scroll, char_ht, status); Put ("size :"); IM_STD_SIZE_MODE_IO.Put (size); New_Line; Put ("video :"); IM_STD_VIDEO_MODE_IO.Put (video); New_Line; Put ("scroll:"); IM_SCROLL_MODE_IO.Put (scroll); New_Line; Put ("char_ht :"); IM_CHARACTER_HEIGHT_IO.Put (char_ht); New_Line; else Put_Line ("Set Disp Mode error:"); im_message(status); New_Line; end if; Put_Line("Press any key"); Get(inchar); -- Reset display to some standard mode status := im_set_display_mode (IM_SIZE_MODE_80X25, IM_STD_VIDEO_MODE_3, IM_LCD_SCROLL_AT_25, IM_STANDARD_CHAR_HEIGHT); end dispmode;
B-4
Page 235
KEYCLICK.ADA
B
KEYCLICK.ADA -- File Name: keyclick.ada --- Purpose : This sample program demonstrates how to enable and disable -the click when a key is pressed on the reader keypad. It -uses Intermec’s Ada function im_set_keyclick and the procedure -im_get_keyclick to retrieve the current status. --- COPYRIGHT (c) 1994 INTERMEC CORPORATION, ALL RIGHTS RESERVED With System, Bit, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Bit, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure keyclick Is keyclick_status : IM_CONTROL; status_code : System.Word; in_char : Character := ' '; begin im_get_keyclick (keyclick_status, status_code); if keyclick_status = IM_ENABLE then Put_Line ("Keyclick ENABLED"); else Put_Line ("Keyclick DISABLED"); end if; status_code := im_set_keyclick (IM_DISABLE); if im_isgood(status_code) then Put_Line ("Keyclick DISABLED"); Put_Line ("q to quit"); loop exit when in_char = 'q'; Get (in_char); end loop; else Put_Line ("Disable Keyclick error:"); im_message(status_code); New_Line; end if; in_char := ' '; New_Line; status_code := im_set_keyclick (IM_ENABLE); if im_isgood(status_code) then Put_Line ("Keyclick ENABLED"); Put_Line ("q to quit"); loop exit when in_char = 'q'; Get (in_char); end loop;
B-5
Page 236
KEYCLICK.ADA else Put_Line ("Enable Keyclick error:"); im_message(status_code); New_Line; end if; end keyclick;
B-6
Page 237
PWR_STAT.ADA
B
PWR_STAT.ADA -- File Name: pwr_stat.ada --- Purpose: This sample program demonstrates Intermec’s -Ada procedure im_power_status. It retrieves the AC line status, -battery status, backup battery status, and the percentage -of remaining life in the battery. --- COPYRIGHT (c) 1994 INTERMEC CORPORATION, ALL RIGHTS RESERVED With System, Text_IO, Intrmecd_IO, Intrmecp_IO; Use System, Text_IO, Intrmecd_IO, Intrmecp_IO; procedure pwr_stat 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");
B-7
Page 238
PWR_STAT.ADA when IM_CRITICAL_BAT => Put_Line("Charge critical"); when IM_CHARGING_BAT => Put_Line("Charging battery"); 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 gauge % "); 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 pwr_stat;
B-8
Page 239
XCOMM.ADA
B
XCOMM.ADA -- File Name: xcomm.ada --- Purpose : This sample program receives data from the communications -port 1 and transmits the same data back across the comm1 -port. It expects a carriage return as the end-of-message -character. Program execution continues until the operator -sends a 'q' as the first byte in the buffer. This program -uses Intermec’s Ada procedures im_receive_buffer_noprot, -im_transmit_buffer_noprot, im_cancel_rx_buffer, and -im_cancel_tx_buffer. --- COPYRIGHT (c) 1994 INTERMEC CORPORATION, ALL RIGHTS RESERVED With System, Intrmecd_IO, Intrmecp_IO, Text_IO; Use System, Intrmecd_IO, Intrmecp_IO, Text_IO; procedure xcomm 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; 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);
B-9
Page 240
XCOMM.ADA
-- 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"); 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;
B-10