Functions

ANSI C Functions

To facilitate application development on Opticon handheld terminals, almost all of the standard ANSI C functions plus many other functions for controlling the handheld terminal can be used.
The standard library supplied by the compiler package contains the code for almost all of the ANSI functions. Code that is specific to the handheld terminal is included in the operating system. The start-up code contains the references to these functions. The prototypes of the supported ANSI functions are described in the include files described below in this paragraph. The prototypes of the non-ANSI functions are in the include file LIB.H.

The ANSI functions are not described in this manual. For a description of the ANSI standard library functions you can consult for example the book
'The C programming language, second edition' by Brian Kernighan and Dennis Ritchie (ISBN number 0-13-110362-8, publisher Prentice Hall).

Click on the link below to get an overview of the ANSI C header files and their descriptions on how they conform or deviate from the ANSI standard.

List of ANSI C header files

errno.h The ERRNO.H include file defines several macros that all relate to the reporting of error conditions mainly related to file handling routines. It is included and conforms to the ANSI specifications.
float.h, limits.h These files define macros that expand to various limits and parameters for floating point (FLOAT.H) and integral types (LIMITS.H). They are included and conform to the ANSI specifications.
math.h Math.h contains the definitions of the commonly used mathematics functions. It is included and conforms to the ANSI specifications.
stdarg.h This file defines macros and data types for processing a variable number of arguments on a function call. It is included and conforms to the ANSI specifications.
stddef.h This include file defines some types. It is included and conforms to the ANSI specifications.
stdio.h The stdio.h file contains type declarations, macros and functions for several I/O related functions.
stdlib.h This file declares functions for number conversion, storage allocation and similar tasks. All ANSI functions prototyped in STDLIB.H are supported except for the following functions that are not very useful on embedded systems: atexit(), system(), and getenv().
string.h Defines functions for string and memory manipulation. It is included and conforms to the ANSI specifications.
time.h Additional to the ANSI time functions, the operating system has several easy to use functions for time and date handling: SetTime(), SetDate(), GetTime(), GetDate().

Operating System functions

In this chapter you'll find the available Operating System C functions grouped by categories.

To use these functions, include "lib.h" in your source files.

lib.h Contains all available Operating System C functions with CamelCase names and defines
lib_legacy.h This file is included in lib.h for backwards compatibility, using lower case function names.

Click on the links below to show the related C functions and their descriptions

1. Configuration functions
  • SystemSetting
  • Used to change a large diversity of system settings
  • ExecuteMenuLabel
  • Can be used to execute Universal Menu Book labels like a barcode reader
  • SystemSettingsMemorizing
  • Can be used to store and restore decoder configurations using flash memory
  • ApplicationSettingsMemorizing
  • Can be used to store and restore application configurations using flash memory
  • AddMenuOptionTable
  • Can be used to override OS handling of menu options with custom implementations
    2. Scanner functions
  • ReadBarcode
  • Tries to fetch a barcode from the scanner
  • IsScannerOff
  • Checks whether the scan engine is off
  • ScannerPower
  • Controls the power of the scan engine of the handheld terminal
  • ClearKeyAsTrigger
  • Allows the clear key to be used a trigger key to read barcodes
    3. Led/Sound/Vibrate functions
  • GoodReadLed
  • Controls the good read (typically main) LED
  • Sound
  • Sounds one tone or a sequence of tones
  • IsBuzzerOn
  • Returns whether the buzzer is busy or not
  • Vibrate
  • Controls the vibrating motor (if present)
    4. Keyboard functions
  • DownPressed
  • Returns the current state of the function key
  • kbhit
  • Checks to see if a keystroke is available
  • ResetKey
  • Clears the keyboard buffer
  • TriggerPressed
  • Returns the current state of the trigger key
  • WaitKey
  • Blocks program execution until a key is pressed
    5. Communication functions
  • ComOpen
  • Opens a port for communication
  • ComClose
  • Closes a communications port
  • GetCom
  • Reads a character from the communications port that was opened last by ComOpen()
  • GetCom2
  • Reads a character from the specified communications port
  • GetCTS
  • Returns the level of the CTS line. Only works with USB Serial ports
  • GetDSR
  • Returns the level of the DSR line. Only works with USB Serial ports
  • OseComm
  • Communication protocol to transmit and receive one or more complete files through a serial communications port
  • PutCom
  • Putcom transmits a character through the communications port that was last opened by ComOpen()
  • PutCom2
  • Putcom2 transmits a character through the specified communications port
  • ResetReceive
  • Resets the receive buffers of last opened COM-port
  • SetDTR
  • Sets the level of the DTR line. Only works with USB Serial ports
  • SetRTS
  • Sets the level of the RTS line (Only works with USB-VCP ports)
  • SetRING
  • Sets the level of the RING line (Only works with USB Serial ports)
  • PutString
  • Transmits a null terminated string through the communications port that was last opened by ComOpen()
  • PutString2
  • Transmits a null terminated string through the specified communications port
  • PutnString
  • Transmits n characters of a character buffer through the communications port that was last opened by ComOpen()
  • PutnString2
  • Transmits a n byte/char buffer of the specified length through the specified communications port
  • UsbIsConnected
  • Returns the USB connection state (boolean)
  • UsbIsPowered
  • Returns whether is USB cable is connected (boolean)
  • UsbStatus
  • Returns the USB connection state (enum)
    6. Bluetooth functions
  • BltIsConnected
  • Returns the Bluetooth connection state
  • GetBltAddress
  • Reads the Bluetooth address from flash
  • GetBltLocalName
  • Reads the localname stored in flash ROM
  • SetBltLocalName
  • Stores the Bluetooth localname in flash memory
  • GetBltLocalAddress
  • Returns the local Bluetooth address
  • BltUnpair
  • Remove stored device pairings and link keys
    7. Power management functions
  • AutoPowerDown
  • Sets the auto-power-down settings
  • GetBatteryVoltage
  • Returns the output voltage level of the battery in mVolts
  • Idle
  • Sets the reader in a 'sleep' mode to reduce the power consumption
  • IsColdBoot
  • This function is used to find out if the device has been automatically powered off or has performed a full reset (cold boot)
  • PoweredDown
  • This function is used to find out if the handheld terminal has been powered down
  • IsCharging
  • Returns the current charging state of the terminal
  • GetBatteryLevel
  • Returns the remaining battery capacity as a percentage of the full charge.
    8. Timer functions
  • Delay
  • Waits for a time specified by its argument
  • DelayMs
  • Waits for a specified number of millseconds
  • StartTimer
  • Starts the time-out timer, which can be used to implement time-outs in an application
  • EndTimer
  • Checks if the time specified with the StartTimer() function has elapsed
  • TimerValue
  • Returns the time that is left of the time specified with the StartTimer() function
  • GetSystemTime
  • Returns the current value of the continuously running system timer
  • SetSystemTime
  • Sets the specified value in the continuously running system timer
  • GetTickCount
  • Returns the number of timer ticks that have occurred since startup of the OS
  • SetTickCount
  • Artifically set the number of timer ticks that have occurred since startup of the OS
  • InstallHeartbeatHandler
  • Installs a callback function that is called every 20ms by the operating system
  • RemoveHeartbeatHandler
  • Removes a callback function that was previously installed with a call to InstallHeartbeatHandler
  • SetAlarm
  • Function to wakeup the terminal at a specific time
  • IsAlarmOn
  • This function returns whether a alarm is set
    9. Date/Time functions
  • CheckDate
  • Checks if the date structure passed to the function holds a valid date
  • CheckTime
  • Checks if the time structure passed to the function holds a valid time
  • GetDate
  • Fills in the date structure with the current date stored in the terminal's real-time clock
  • GetTime
  • Fills in the time structure with the current time as stored in the terminal's real-time clock
  • GetDateTime
  • Fills in a time structure and a date structure with the current time and date stored in the terminal's real-time clock
  • SetDate
  • Sets the date in the terminal's real-time clock to the date in the date structure
  • SetTime
  • Sets the time in the terminal's real-time clock to the time in the time structure
  • SetDateTime
  • Sets the time and date in the terminal's real-time clock to the time in the time structure and the date in the date structure
    10. Memory/file functions
  • CoreLeft
  • Returns the amount of memory that is still available to the user
  • Heap_CoreLeft
  • Returns the amount of memory that is still available to the user for allocating memory for variables
  • format
  • Deletes all files in the RAM disk and initializes the heap
  • fsize
  • Returns the size of a file, measured in bytes
  • chsize
  • Changes the size of a file
    11. Miscellaneous
  • GetSerialNumber
  • Returns the serial number that is printed on the device
  • GetTerminalId
  • Returns the configured terminal ID
  • GetOsVersion
  • Returns the version of the Operating System
  • GetBootVersion
  • Returns the version of the Bootlader
  • GetApplVersion
  • Returns the version of the Application
  • SetTerminalId
  • Set the terminal ID