C Language Development Kit/Functions

From OptiWiki

Jump to: navigation, search

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 in the file libOPH100x.a (for the OPH100x terminal) or STARTxxx.OBJ (for the other terminals) contains the references to the functions in the operating system. libOPH100x.a or STARTxxx.OBJ is linked to the application by the linker. 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).

List of ANSI C header files

ASSERT.H This include file defines the assert macro for putting diagnostics into programs. It is included and conforms to the ANSI specifications.
CTYPE.H This include file defines macros and functions for handling characters. It is included and conforms to the ANSI specifications.
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.
LOCALE.H This include file is not included. It normally contains definitions of functions that can be used to get language-related information, like the symbol for the decimal point. These functions are not supported because they are rarely used.
MATH.H MATH.H contains the definitions of the commonly used mathematics functions. It is included and conforms to the ANSI specifications. Note that you must also link Microtec's™ floating point library to your application when you use functions from MATH.H. Refer to the Microtec™ manual for an explanation how to do this.
SETJMP.H The standard include file SETJMP.H defines two functions (setjmp()<code> and <code>long jmp()) and a type (jmp_buf) for setting up nonlocal jumps. They are included and conform to the ANSI specifications.
SIGNAL.H The functions in this include file are not supported. Normally SIGNAL.H defines numerous symbolic constants and macros used to process 'signals' or interrupts. It means that the functions signal() and raise() are not supported.
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. Almost all the ANSI functions are supported, except for the tmpfile() and tmpnam() functions. Apart from this, the %f, %e and %g parameters in the printf() and scanf() functions are not supported. (Since printf()/scanf() functions are used very often, it is not wise to add a large amount of code to support the hardly ever-used floating-point parameters). However, to convert floating point variables to a string the library functions ftoa() and dftoa() can be used on some terminals.
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 The ANSI time functions are not supported. This is done, because the ANSI time functions relate heavily on the (ancient) UNIX implementation of a system clock. Instead of 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 find the available Operating System C functions grouped by categories. If you do not find certain functions, please remember that standard ANSI C functions are not listed here. You can check their availability in the ANSI C header files that are delivered with the Microtec or Toshiba compiler.

The functions are grouped according to the following activities: Click on the links below to show the related C functions and their descriptions

  1. General functions
    • systemsetting Used to change a large diversity of system settings
  2. Scanner functions
    • readbarcode Tries to fetch a barcode from the scanner
    • scanneroff Checks whether the scan-engine is off
    • scannerpower Controls the power of the scan-engine of the handheld terminal
  3. Display functions
    • contrast Controls or reads the contrast of the display
    • wherex Returns the X-coordinate of the current cursor position
    • wherey Returns the Y-coordinate of the current cursor position
    • cursor Controls the appearance of the cursor and behavior at the end of the line
    • definecharacter Defines the shape of the symbols with ASCII values 0 through 7
    • drawline Draws a line on the LCD-display
    • flipscreen Makes it possible to display the screen content up side down
    • getfontsize Returns the width and the height of a character of the current font
    • getindicator Retrieves the state of various screen indicators
    • gotoxy Moves the cursor position to a new location
    • printsymbol This function prints a symbol on the screen
    • setecho Sets the echo mode on or off, or returns the current echo mode
    • setfont Selects a character font
    • setpixel Sets, clears or inverts a pixel on the display
    • loaddisplay Restores the pixels of a screen display that were previously stored in a file
    • savedisplay Saves the pixels of a screen display into a file
    • set_offset Aligns a character in the Y-direction on the screen
    • showpicture Places a bitmap on the screen
  4. Led/sound functions
    • goodreadled Controls the good read LED
    • sound Sounds one tone or a sequence of tones
    • isBuzzerOn Returns whether the buzzer is busy or not
  5. Keyboard functions
    • downpressed Returns the current state of the down key
    • kbhit Checks to see if a keystroke is available
    • resetkey clears the keyboard buffer
    • setshifttimer Sets the time it takes for a shifted key to be accepted as an entered character
    • shiftstate Sets or returns the state of the shift mode
    • triggerpressed Returns the current state of the trigger key
    • uppressed Returns the current state of the up key
  6. Serial Communication functions
    • comopen Opens a port for serial communication
    • comclose Closes a serial communications port previously opened by comopen()
    • getcom Reads a character from the serial communications port that was opened last by comopen()
    • getcom2 Reads a character from the specified serial communications port.
    • getCTS Returns the level of the CTS line. Only works with COM0 (direct serial cable)
    • getDSR Returns the level of the DSR line. Only works with COM0 (direct serial cable)
    • xmodemreceive Uses the Xmodem protocol to receive blocks of data through a serial communications port
    • xmodemtransmit Uses the Xmodem protocol to transmit data through a serial communications port
    • neto_receive, neto_receive2 Uses the NetO protocol to receive one or more complete files through a serial communications port
    • neto_transmit, neto_transmit2 Uses the NetO protocol to transmit one or more complete files through a serial communications port
    • putcom Putcom transmits a character through the serial communications port that was last opened by comopen()
    • putcom2 Putcom2 transmits a character through the specified serial communications port
    • resetreceive Resets the serial receive buffers and electronics of last opened COM-port
    • resetreceive2 Resets the serial receive buffers and electronics of the specified COM-port
    • setDTR Sets the level of the DTR line. Only works with COM0 (direct serial cable)
    • setRTS Sets the level of the RTS line (for direct serial cable)
  7. Bluetooth functions
    • blt_is_connected Checks if there is a bluetooth connection in the RFCOMM layer
    • blt_discovery Discovers up to 10 available bluetooth devices in the neighborhood
    • com_idle Starts or exits a Bluetooth low power mode
    • GetBltAddress Reads the bluetooth address from flash
    • GetBltLocalName Reads the localname stored in flash ROM
    • GetBltPin Reads the bluetooth pincode that is needed for authentication from flash
    • SetBltAddress Stores the bluetooth address in flash memory
    • SetBltLocalName Stores the bluetooth localname in flash memory
    • SetBltPin Stores the bluetooth pincode in flash memory
  8. Power management functions
    • autopowerdown Sets the auto-power-down settings
    • backlight Controls the backlight on the LCD-display
    • batteryvoltage Returns the output voltage level of the battery pack
    • battlevel Returns an estimate of the remaining charge left in the battery pack
    • idle Sets the reader in a 'sleep' mode to reduce the power consumption
    • powereddown This function is used to find out if the handheld terminal has been powered down
  9. Timer functions
    • delay Waits for a time specified by its argument
    • 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 to start-up of the OS
    • timercallback Provides the operating system with a pointer to a user defined function
    • SetAlarm Function to wakeup the terminal at a specific time.
  10. 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
    • 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
  11. Memory/file functions
    • coreleft Returns the amount of memory that is still available to the user
    • coreleft2 Returns the amount of free space on the specified drive
    • far_malloc Allocates a block of memory from the heap to be used by the program
    • findfirst Searches the RAM-disk directory, in order to try to find the first occurrence of a specified filename
    • findnext Continues the search started with the findfirst() function
    • format Deletes all files in the RAM disk and initializes the heap
    • format2 Deletes all files on the specified drive
    • fsize Returns the size of a file, measured in bytes
    • fcopy Creates a copy of an existing file at a specified location
    • runapplfromfile Loads a file in the application flash memory of the handheld terminal
    • clearheap Clears and initializes the heap
    • set_default_drive Sets the default drive
  12. Miscellaneous
    • downloadapplication Switches the terminal into a mode in which the user can install a new application
    • getterminalid Returns the number that is set in the system menu, under the "Set terminal ID" option
    • setterminalid Sets the id of the terminal
    • GetOsVersion Returns the version of the currently loaded operating system
    • GetBootVersion Returns the version of the ROM of the handheld terminal
    • version_os Returns the version of the currently loaded operating system
    • version_rom Returns the version of the ROM of the handheld terminal
    • vibrate Controls the vibrating motor (if present)
  13. GPS functions
Views
Personal tools