background image

 

Printed on 20 March, 2006 

        

"C" Programming Guide 

 

Version 3.04.02 

 

 

 

Optimus S 
Optimus R 

Содержание Optimus R

Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...

Страница 2: ...is confidential between the Company and the client and remains the exclusive property of the Company If you find any problems in the documentation please report them to us in writing The Company does...

Страница 3: ...12 2 4 C Compiler 12 2 4 1 Size of Types 13 2 4 2 Representation Range of Integers 13 2 4 3 Floating Types 14 2 4 4 Alignment 14 2 4 5 Register and Interrupt Handling 14 2 4 6 Reserved Words 14 2 4 7...

Страница 4: ...3 8 LCD 80 3 8 1 Properties 81 3 8 2 Cursor 84 3 8 3 Display 87 3 8 4 Clear 92 3 8 5 Image 94 3 9 Fonts 96 3 9 1 Font Size 96 3 9 2 Display Capability 96 3 9 3 Multi Language Font 97 3 9 4 Special Fon...

Страница 5: ...h 221 4 3 String Functions string h 222 4 3 1 Functions start with str 222 4 3 2 Functions start with mem 223 4 4 Mathematical Functions math h 224 4 5 Utility Functions stdlib h 226 4 5 1 Number Con...

Страница 6: ......

Страница 7: ...es a concise introduction about the C Compiler and the development flow for applications which provides step by step description in developing application programs for the portable data terminals with...

Страница 8: ...2 C Programming Guide For Optimus S R...

Страница 9: ...contains six directories namely BIN ETC INCLUDE LIB README and USER The purposes and contents of each directory are listed below To set up the C language development environment on your PC you may cr...

Страница 10: ...via RS 232 IrDA Cradle IR or TCP IP 2 1 2 ETC It contains help and version information of the C Compiler 2 1 3 INCLUDE It contains header files C header files for standard library routines assert h ct...

Страница 11: ...ust for the compiler to locate all necessary files set tmp C tmp This is the temporary working directory for the compiler and linker for memory and file swapping Skip this if tmp is already specified...

Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...

Страница 13: ...ME C This batch file invokes the C compilation program which in turn calls many other executable programs under the BIN directory As these programs are invoked by the compiler sequentially their usage...

Страница 14: ...ograms are successfully compiled into relocatable object files the linker must be used to create the absolute objects and then the file can be downloaded to the target machine s flash memory for execu...

Страница 15: ...andard library User could provide suitable values to the following variables MainStackSize 0x001000 HeapSize 0x000100 MaxSysRamSize 0x020000 Do not modify anything beyond this line memory IRAM org 0x0...

Страница 16: ...f_area RAM data org org code sizeof code addr org area sizeof area f_data global variables with initial values xcode org org data sizeof data addr addr data sizeof data f_xcode code reside on RAM RAM_...

Страница 17: ...rg icode sizeof icode f_const f_tail ROM ActualRamSize addr xcode sizeof xcode 3 4 4 0x205000 long boundary SysRamEnd org area MaxSysRamSize long boundary DataRam addr data XCodeRam addr xcode ICodeRa...

Страница 18: ...d if no error is found 2 3 5 Download Program to Flash Memory Now that the Motorola S format object file FILENAME shx is created successfully it can be downloaded to the flash memory for testing Run t...

Страница 19: ...SCHAR_MIN minimum value of signed char type SCHAR_MAX maximum value of signed char type CHAR_MIN minimum value of char type CHAR_MAX maximum value of char type UCHAR_MAX maximum value of unsigned cha...

Страница 20: ...and is fixed to 1 for all types In invoking the C compiler driver XA1 XD1 XC1 and Xp1 is specified 2 4 5 Register and Interrupt Handling Register and interrupt handling are possible through C However...

Страница 21: ..._ _DMAS2 _ _DMAS3 _ _DMAD0 _ _DMAD1 _ _DMAD2 _ _DMAD3 _ _DMAC0 _ _DMAC1 _ _DMAC2 _ _DMAC3 _ _DMAM0 _ _DMAM1 _ _DMAM2 _ _DMAM3 _ _NSP _ _XNSP _ _INTNEST 2 4 8 Bit Field Usage The following types can b...

Страница 22: ...t bits Little endien If the base type of a bit field member is a type requiring two bytes or more e g unsigned int the data is stored in memory after its bytes are turned upside down Different types d...

Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...

Страница 24: ...18 C Programming Guide For Optimus S R...

Страница 25: ...library routines as well as the declaration of the system variables can be found in the library header file lib_ops h or lib_opr h It is assumed that the programmer has prior knowledge of the C langu...

Страница 26: ...Sixteenth 2 Eighth 3 Quarter 4 Half 5 Full Return None CheckWakeUp Optimus S Purpose To check the wakeup event Syntax int CheckWakeUp void Example event CheckWakeUp Description This routine checks on...

Страница 27: ...le SetPwrKey 1 enable the POWER key for waking up the terminal Description The parameter mode is set to one of the following values POWER_KEY_DISABLE 0 The POWER key is disabled POWER_KEY_ENABLE 1 The...

Страница 28: ...de For Optimus S R system_restart Purpose To restart the system Syntax void system_restart void Example system_restart Description This routine simply jumps to the Power On Reset point and restarts th...

Страница 29: ...all disabled Reader ports all disabled Keypad scanning enabled LCD initialized and cleared to blank cursor is on and set to the upper left corner 0 0 Calendar initialized LED off Allocate stack area a...

Страница 30: ...m to automatically shut down the user s program whenever there is no operation during the preset period When it is set to 0 the AUTO_OFF function will be disabled extern unsigned int POWER_ON This var...

Страница 31: ...ls By default it is set to 1 i e 3 seconds 1 3 sec 2 8 sec 3 12 sec 4 16 sec 5 20 sec 6 25 sec 7 30 sec 8 40 sec extern int BC_X BC_Y These two variables govern the location of the battery icon i e on...

Страница 32: ...attery charging events For the Optimus S it is possible to wake up the terminal by one of the following pre defined events PwrKey_WakeUp when the POWER key is pressed Alarm_WakeUp when the alarm time...

Страница 33: ...e current system information is displayed Note The Kernel Menu is launched by pressing three keys simultaneously 1 7 and the POWER key Step 2 Press down 1 7 for approximately 3 seconds Step 3 Type the...

Страница 34: ...nalSerialNumber SerialNumber FontVersion Purpose To get version information of font file Syntax void FontVersion void Example printf FONT s FontVersion Description By default the version information w...

Страница 35: ...lso DeviceType FontVersion GetRFmode KernelVersion KeypadLayout LibraryVersion ManufactureDate NetVersion OriginalSerialNumber SerialNumber KernelVersion Purpose To get version information of kenel Sy...

Страница 36: ...ptimus R lib_opr lib Return It always returns a pointer indicating where the information is stored See Also DeviceType FontVersion GetRFmode HardwareVersion KernelVersion KeypadLayout ManufactureDate...

Страница 37: ...ntax void OriginalSerialNumber void Example printf S N s OriginalSerialNumber Description This routine gets the original serial number of the terminal Note that if the original serial number is it mea...

Страница 38: ...whether the system password is enabled or not By default the System Menu is not password protected Return If enabled it returns 1 Otherwise it returns 0 i e no password required See Also CheckSysPass...

Страница 39: ...ting Enter it returns 1 If input is cancelled by hitting ESC it returns 0 See Also CheckPasswordActive CheckSysPassword SaveSysPassword SaveSysPassword Purpose To save or change the system password Sy...

Страница 40: ...name Otherwise it will be named as Unknown automatically This file name may be changed by rename if necessary A program in the file system can be loaded to the Program Manager flash memory by calling...

Страница 41: ...RAM Syntax int DownLoadProgram char filename int comport int baudrate char filename pointer to a buffer where filename of the program is stored int comport COM1 or COM2 for transmission int baudrate a...

Страница 42: ...ar programtype pointer to a buffer where program type is stored char programname pointer to a buffer where program name is stored Example val ProgramInfo 2 typebuffer namebuffer Description This routi...

Страница 43: ...h memory the new program will replace the old one Otherwise it will be stored in an automatically assigned residence location Return If successful it returns the residence location of program i e slot...

Страница 44: ...ter not included The original program resided in the active area will then be replaced by the new program While replacing the program the POWER key is disabled to protect the system If successful this...

Страница 45: ...Decode function can be called in the program loops to perform barcode decoding Below are four global variables related to the barcode decoding routines These variables are declared by the system and t...

Страница 46: ...EAN 8 with Addon 2 78 N Italian Pharmacode 66 B EAN 8 with Addon 5 79 O CIP 39 67 C EAN 13 80 P Industrial 25 68 D EAN 13 with Addon 2 81 Q Interleave 25 69 E EAN 13 with Addon 5 82 R Matrix 25 70 F M...

Страница 47: ...talian Pharmacode 0 5 1 Enable CIP 39 0 Disable CIP 39 0 4 1 Enable Industrial 25 0 Disable Industrial 25 0 3 1 Enable Interleave 25 0 Disable Interleave 25 0 2 1 Enable Matrix 25 0 Disable Matrix 25...

Страница 48: ...lepen Numeric 2 0 1 Enable RSS14 Limited 0 Disable RSS14 Limited 3 7 1 Enable RSS14 Expanded 0 Disable RSS14 Expanded 3 6 1 Enable RSS14 0 Disable RSS14 3 5 1 Transmit RSS14 Code ID 0 DO NOT transmit...

Страница 49: ...ansmit Italian Pharmacode Check Character 5 2 1 Transmit CIP 39 Check Character 0 DO NOT transmit CIP 39 Check Character 5 1 1 Verify Interleave 25 Check Digit 0 DO NOT verify Interleave 25 Check Digi...

Страница 50: ...cd abcd 01 abcd tn e 10 ABCD ABCD 11 ABCD TN E 7 3 1 Transmit Codabar Start Stop Character 0 DO NOT transmit Codabar Start Stop Character 7 2 0 Reserved 8 7 0 Reserved 9 7 6 MSI Check Digit Verificati...

Страница 51: ...NOT transmit UPCE System Number 10 0 1 Transmit UPCA System Number 0 DO NOT transmit UPCA System Number 11 7 1 Convert EAN 8 to EAN 13 0 No conversion 11 6 Reserved 11 5 1 Enable GTIN 0 Disable GTIN...

Страница 52: ...de Length Fixed Length 1 17 7 0 Matrix 25 Min Code Length Fixed Length 2 18 7 1 MSI 25 Code Length Limitation in Max Min Length Format 0 MSI 25 Code Length Limitation in Fixed Length Format 18 6 0 MSI...

Страница 53: ...l to define a scan mode that best suits the requirements of a specific application If necessary set the 22nd byte for timeout duration ON OFF Scan Mode Always Press trigger once Hold trigger Press tri...

Страница 54: ...The reader is always scanning but only one decoding is allowed for the same barcode That is to read i e scan and decode the same barcode multiple times the barcode must be re approached for new scanni...

Страница 55: ...3 Terminal Specific Function Library 49 Test mode The reader is always scanning for testing purpose Comparing to the Continuous mode it will decode repeatedly even with the same barcode without re app...

Страница 56: ...ter a successful reading the same data will be re transmitted without actually reading the barcode Such re transmission can be activated as many times as needed as long as the time interval between ea...

Страница 57: ...Chapter 3 Terminal Specific Function Library 51 Momentary mode Hold down the scan trigger to start scanning The scanning continues until the trigger is released...

Страница 58: ...52 C Programming Guide For Optimus S R Alternate mode Press the scan trigger to start scanning The scanning continues until the trigger is pressed again...

Страница 59: ...ct barcode will be scanned Press the scan trigger to aim at a barcode Within one second press the trigger again to decode the barcode The scanning continues until one of the events happens 1 A barcode...

Страница 60: ...R Laser mode This mode is most often used on laser scanners Hold down the scan trigger to start scanning The scanning continues until one of the events happens 1 A barcode is read 2 The preset timeou...

Страница 61: ...Function Library 55 Auto Off mode This is the default mode The reader will start to scan once the scan trigger is pressed The scanning continues until one of the events happens 1 A barcode is read 2...

Страница 62: ...tart to scan once the scan trigger is pressed The scanning continues until one of the events happens 1 The preset timeout expires Comparing to the Auto Off mode the reader continues to scan whenever t...

Страница 63: ...And integer variable CodeLen as well as the character variable CodeType will reflect the length and code type of the decoded data respectively Return If successful it returns an integer whose value e...

Страница 64: ...58 C Programming Guide For Optimus S R Description The scanner port will not work unless it is initialized Return None See Also Decode HaltScanner1...

Страница 65: ...unsigned char WedgeSetting 3 This unsigned character array governs the operation of the SendData routine 3 3 1 Definition of the WedgeSettingArray Subscriptor Bit Description 0 7 0 KBD Terminal Type...

Страница 66: ...002 8A 003 8A 5 PCAT SV 26 IBM 3477 TYPE 4 6 PCAT NO 27 PS2 30 7 PCAT UK 28 Memorex Telex 122 Keys 8 PCAT BE 29 PCXT 9 PCAT SP 30 IBM 5550 10 PCAT PO 31 NEC 5200 11 PS55 A01 1 32 NEC 9800 12 PS55 A01...

Страница 67: ...though the auto detection setting is enabled To enable Capital Lock Auto Detection add 128 to the value of the second element of the WedgeSetting array 3 3 4 Capital Lock Status Setting In order to se...

Страница 68: ...user is sure about the selection 3 3 7 Shift Capital Lock Keyboard This setting can force the SendData routine to treat the keyboard type to be a shift lock keyboard or a capital lock keyboard This s...

Страница 69: ...ng 2 10 3 3 10 Composition of Output String The keyboard wedge character mapping is shown below Each character in the output string is translated by this table when the SendData routine transmits data...

Страница 70: ...ombination status key after sending the next character For example to send A Ctrl Insert 5 scan code 0x29 Tab 2 Shift Ctrl A B Alt 1 Alt 2 Break Alt 1 Alt 3 the following characters are inserted into...

Страница 71: ...d Example if WedgeReady SendData CodeBuf Description Before sending data via keyboard wedge it is recommended to check if the cable is well connected otherwise the transmission may be blocked Return I...

Страница 72: ...how the beeper is activated It comprises a number of pairs of beep frequency and duration Each pair is one beep When the value of the beep duration is set to 0 it means the end of a beeper sequence i...

Страница 73: ...ption This routine checks if there is a beeper sequence in progress Return If beeper sequence is undergoing it returns 1 Otherwise it returns 0 See Also off_beeper on_beeper play off_beeper Purpose To...

Страница 74: ...st char song 0x31 10 0x32 10 0x33 10 0x34 10 0x35 10 0x36 10 0x37 10 0x41 10 0x31 4 0x32 4 0x33 4 0x34 4 0x35 4 0x36 4 0x37 4 0x41 4 0x00 0x00 play song Description This routine is similar to on_beepe...

Страница 75: ...tem time variable sys_msec and sys_sec is maintained by CPU timers and has nothing to do with this calendar chip Accuracy of these two time variables depends on the CPU clock and is not suitable for p...

Страница 76: ...he calendar chip Syntax int set_time char new_time char new_time Example set_time 20050805125800 AUGUST 5 2005 12 58 00 Description This routine sets new date and time new_time to the calendar chip ne...

Страница 77: ...date time and the string terminator The format of the system date and time is YYYYMMDDhhmmss Return None See Also SetAlarm SetAlarm Optimus S Purpose To set the alarm time Syntax void SetAlarm char ne...

Страница 78: ...nt duration duration in units of 10 milli second Example set_led LED_RED LED_FLASH 50 set red LED to flash for each 1 second cycle Description This routine sets the LED operation mode The value of the...

Страница 79: ...fy the type as the last parameter There are two types CHK_EXC 1 exclusive checking only the keys being pressed match the keys specified will the function return 1 CHK_INC 2 inclusive checking as long...

Страница 80: ...Key d pressed c else printf No key pressed Description This routine can be used with menu operation to detect a shortcut key being pressed Return If successful it returns the character read from the k...

Страница 81: ...key click Example SetKeyClick 1 enable key click sound Description There are five different tones available You can choose a tone from the System Menu or through programming Moreover the frequency and...

Страница 82: ...ault the input mode is numeric and can be modified by the ALPHA key If the ALPHA key is disabled by dis_alpha this routine is used to enable it If the ALPHA key is locked by LockAlphaState this routin...

Страница 83: ...is_alpha en_alpha LockAlphaState get_alpha_lock_state Purpose To get information of the ALPHA state for input mode either locked or unlocked Syntax int get_alpha_lock_state void Example state get_alph...

Страница 84: ...lock Purpose To set the ALPHA state for input mode Syntax void set_alpha_lock int state int state input mode that can be modified by ALPHA key Example set_alpha_lock 1 upper case alpha mode ALPHA key...

Страница 85: ...of the FN function key Return The return value can be 0 3 See Also SetFuncToggle SetFuncToggle Optimus R Purpose To set the state of the FN function key Syntax void SetFuncToggle int state int state F...

Страница 86: ...oid Example DecContrast Description This routine decreases the LCD contrast by one level each time it is called and the minimum value is 0 Return None See Also GetContrast IncContrast SetContrast GetC...

Страница 87: ...the maximum value is 7 Return None See Also DecContrast GetContrast SetContrast lcd_backlit Purpose To set the LCD backlight Syntax void lcd_backlit int state int state LCD backlight state Example lcd...

Страница 88: ...urn None See Also DecContrast GetContrast IncContrast SetVideoMode Purpose To set the display mode of the LCD Syntax void SetVideoMode int mode int mode video mode reverse or normal Example SetVideoMo...

Страница 89: ...his routine checks the cursor indication on the LCD i e whether it is visible On or not Off Return If visible it returns 1 Otherwise it returns 0 See Also SetCursor gotoxy Purpose To move the cursor t...

Страница 90: ...tine retrieves the x coordinate of the current cursor position Return It returns the x coordinate See Also wherexy wherey wherexy Purpose To get the x coordinate and y coordinate of the current cursor...

Страница 91: ...Chapter 3 Terminal Specific Function Library 85 Description This routine retrieves the y coordinate of the current cursor position Return It returns the y coordinate See Also wherex wherexy...

Страница 92: ...CON_ZONE int mode int mode 1 for printing enabled 0 for printing disabled default Example ICON_ZONE 1 Description The icon zone refers to an area on the LCD that is reserved for showing status icon su...

Страница 93: ...codes embedded in the format specification format To print values of C variables a format specification must be embedded in format for each variable to be printed The format specification for each va...

Страница 94: ...o x or X see below non zero output values are prefixed with 0 0x or 0X respectively Type Expected Input c d i o u x X s Single character Signed decimal integer Signed decimal integer Octal digits wit...

Страница 95: ...g hourglass on the LCD Syntax void WaitHourglass int UppLeftX int UppLeftY int type int UppLeftX x coordinate of the upper left corner of the hourglass int UppLeftY y coordinate of the upper left corn...

Страница 96: ...ers can show custom icons in this area by using the show_image function When calling clr_scr to clear the screen this icon zone won t be cleared Therefore if you need to erase the icon zone you have t...

Страница 97: ...ion Return None See Also fill_rect clr_scr Purpose To clear everything on the LCD Syntax void clr_scr void Example clr_scr Description This routine clears contents of the current screen and places the...

Страница 98: ...pper left corner of the rectangle int top y coordinate of the upper left corner of the rectangle int width width of the rectangle in dots int height height of the rectangle in dots unsigned char pat p...

Страница 99: ...on This routine displays the bitmap pattern from a buffer pat to a rectangular area on the LCD whose top left position and size are specified by left top width and height The cursor position is not af...

Страница 100: ...ont file is downloaded to the terminal Font Files Custom Font Size SetFont Options System font default N A FONT_6X8 FONT_8X16 Multi language font file N A FONT_6X8 FONT_8X16 Single byte Others He Nd P...

Страница 101: ...racters must be determined by SetFont either 6x12 or 12x12 Otherwise the characters cannot be displayed properly CheckFont Purpose To check which font file resides in the flash memory Syntax int Check...

Страница 102: ...s call The value of the parameter font depends on the current font and its available font size options It can be one of the following FONT_6X8 6x8 graphic dots per character FONT_8X16 8x16 graphic dot...

Страница 103: ...ys change this setting in the System Menu The value of the parameter setting with code page specified can be one of the following 0x10 English_437 English default 0x11 French_863 Canadian French 0x12...

Страница 104: ...12 5 lines Font_OP_Korean shx Font size 16x16 4 lines Font_OP_Simplified_Chinese shx Font size 16x16 4 lines Font_OP_Simplified_Chinese12 shx Font size 6x12 or 12x12 5 lines Font_OP_Traditional_Chines...

Страница 105: ...scription This routine checks the charging progress of the main battery Return The return value can be one of the following CHARGE_STANDBY Not connected to any external power CHARGING The battery is b...

Страница 106: ...gramming Guide For Optimus S R Example bat1 get_vbackup Description This routine reads the voltage level of the backup battery in units of mV Return It returns the voltage reading milli volt See Also...

Страница 107: ...se read and write the data via different interfaces RS 232 Serial IR IrDA or Bluetooth SPP DUN 3 11 2 Receive Transmit Buffers Receive Buffer A 256 byte FIFO buffer is allocated for each port The data...

Страница 108: ...n None See Also com_overrun close_com Purpose To terminate communication and disable a specified COM port Syntax int close_com int port int port COM port to be closed Example close_com 2 close COM 2 D...

Страница 109: ...ers through a specified COM port Syntax int nwrite_com int port char s int count int port COM port to be used char s string to be sent out int count number of characters to be sent Example char s Hell...

Страница 110: ...MMAND Bluetooth Setting 0x00 0x03 0x04 BT SPP Slave BT SPP Master BT DUN BT_SERIALPORT_SLAVE BT_SERIALPORT_MASTER BT_DIALUP_NETWORKING Example open_com 1 0x0b open COM 1 to 38400 8 data bits no parity...

Страница 111: ...ns 0 to indicate the buffer is empty See Also nwrite_com write_com SetCommType Purpose To set the communication type of a specified COM port Syntax int SetCommType int port int type int port COM port...

Страница 112: ...tring Hello n through COM 1 Description This routine sends a string through a specific COM port If any prior transmission is still in progress it will be terminated and then the current transmission r...

Страница 113: ...200 76800 57600 38400 19200 9600 4800 2400 Data Bits 7 or 8 Parity Even Odd or None Stop Bit 1 Flow Control None Flow Control To avoid data loss three options of flow control are supported and done by...

Страница 114: ...ion is enabled Then every character received is examined to see if it is normal data or flow control codes If an XOFF is received transmission is halted It is resumed later when XON is received Just l...

Страница 115: ...he direct RS 232 port Return If asserted it returns 1 i e mark Otherwise it returns 0 i e space See Also com_rts com_rts Optimus R Purpose To set RTS level Syntax void com_rts int port int val int por...

Страница 116: ...PPP Connection via RS 232 It is supported on the Optimus R only when being connected to a generic modem direct RS 232 PPP Connection Practice Follow the same programming flow of WLAN 802 11b Practice...

Страница 117: ...Chapter 3 Terminal Specific Function Library 111 Bluetooth ops_ppp lib or ops_bnep lib Batch opr_ppp lib Bluetooth opr_ppp lib or opr_bnep lib Optimus R 802 11b opr_ppp lib or opr_wlan lib...

Страница 118: ...o a library file such as opr_wlan lib opr_bnep lib ops_wlan lib and ops_bnep lib This file should be specified in the link file of user program It will ask the linker program to search for the TCP IP...

Страница 119: ...N IEEE 802 11b Terminal 8061 8360 8071 8370 Access Point 3560 3570 WLAN stands for IEEE 802 11b PAN stands for Personal Area Networking Profile of Bluetooth SPP stands for Serial Port Profile of Bluet...

Страница 120: ...tically fallback from 11 Mbps to 5 5 2 or 1 Mbps as range increases or signal quality decreases 802 11b Specification Frequency Range 2 4 2 5 GHz Data Rate 11 5 5 2 1 Mbps auto fallback Connected Devi...

Страница 121: ...e commands as for 802 11b TCP IP networking Dial Up Networking Profile DUN makes use of a Bluetooth modem or mobile phone as a wireless modem Bluetooth Specification Frequency Range 2 4 2 5 GHz Data R...

Страница 122: ...cture and are saved in the system They are kept by the system during normal operations and power on off cycles These parameters can be accessed through the System Menu or an application program via Ge...

Страница 123: ...DhcpEnable unsigned char IpAddr 4 unsigned char SubnetMask 4 unsigned char DefaultGateway 4 unsigned char DnsServer 4 char DomainName 129 char LocalName 33 char SSID 33 int SystemScale WLAN_FLAG Flag...

Страница 124: ...l host name By default it shows the serial number of terminal char SSID 33 Null Service Set ID or AP name which is used for Remote Device association int SystemScale 2 Access Point Density determines...

Страница 125: ...e can be used at a time 802 11b or PAN Parameter Bit Default Description WLAN PAN unsigned int Authen 0 1 0 Share Key 1 Open System unsigned int Wep 1 0 0 WEP Key disable 1 WEP Key enable unsigned int...

Страница 126: ...Fail do OSTimeDly 10 GetNetStatus ns while ns IPReady Description This routine gets the whole network configurations from the system It is useful when the application wants to change more than one par...

Страница 127: ...e writes the whole network configurations to the system Before writing the application should make sure that every setting is significant The best way is calling GetNetConfig first to get the original...

Страница 128: ...er Default Description Index char BTRemoteName 20 Null ID used for Remote Device association 25 unsigned char BTPINCode 16 Null PIN Code for pairing usually in Slave mode 27 unsigned char BTLinkKey 16...

Страница 129: ...1 unsigned int Reservedflag 13 BT_FLAG Parameter Bit Default Description Index unsigned int BTPWRSaveON 0 1 Bluetooth Power saving 0 disable 1 enable 29 unsigned int BTSecurity 1 0 Bluetooth Security...

Страница 130: ...ey 16 BTSearchInfo size 51 bytes Parameter Default Description unsigned char Machine 0 Host profile indication 0 empty 1 AP 3 SPP 4 DUN If bit 7 1 it means the device is currently connected unsigned c...

Страница 131: ...Return None See Also GetNetParameter SetBTConfig SetBTConfig Purpose To write the whole Bluetooth configurations to the system Syntax void SetBTConfig BTCONFIG config Example Description This routine...

Страница 132: ...e 20 unsigned char LoginPassword 20 int ComBaudRate PPPCONFIG Parameter Default Description Index unsigned char DialUpPhone 20 Null Phone number of ISP 70 unsigned char LoginName 20 Null Login user na...

Страница 133: ...ned char 14 9 P_WEPKEY_2 unsigned char 14 10 P_WEPKEY_3 unsigned char 14 11 P_DHCP_ENABLE int 12 P_AUTHEN_ENABLE unsigned int 13 P_WEP_LEN int 14 P_SYSTEMSCALE int 15 P_DEFAULTWEPKEY int 16 P_DOMAINNA...

Страница 134: ..._DEVICE1 BTSearchInfo 41 P_BT_FREQUENT_DEVICE2 BTSearchInfo 42 P_BT_FREQUENT_DEVICE3 BTSearchInfo 43 P_BT_FREQUENT_DEVICE4 BTSearchInfo 44 P_BT_FREQUENT_DEVICE5 BTSearchInfo 45 P_BT_FREQUENT_DEVICE6 B...

Страница 135: ...IP 4 DhcpEnable 1 SetNetParameter void DhcpEnable P_DHCP_ENABLE if NetInit 0 printf Initialization Fail do OSTimeDly 10 GetNetStatus ns while ns IPReady GetNetParameter void IP P_LOCAL_IP printf IP d...

Страница 136: ...SetNetParameter void DhcpEnable P_DHCP_ENABLE if NetInit 0 printf Initialization Fail do OSTimeDly 10 GetNetStatus ns while ns IPReady GetNetParameter void IP P_LOCAL_IP printf IP d d d d IP 0 IP 1 I...

Страница 137: ...e called again Note Any previous network connection and data will be lost after calling NetClose NetInit Purpose To perform TCP IP networking initialization Syntax int NetInit void int NetInit unsigne...

Страница 138: ...t Bluetooth PAN NetInit NetInit Bluetooth DUN GPRS NetInit 3 NetInit 3 PPP via IR NetInit 4 NetInit 4 NetInit 4 PPP via RS 232 NetInit 5 NetInit 5 Return If successful it returns 0 On error it returns...

Страница 139: ...ucture and the system will periodically update it Note User program must explicitly call CheckNetStatus to get the latest status WLAN 802 11b Status NETSTATUS Structure struct NETSTATUS int State int...

Страница 140: ...ps 5 int IPReady Terminal IP Status for both WLAN and Bluetooth 1 0 1 Error Not Ready Ready 6 Note IPReady is used for both WLAN 802 11b and Bluetooth GetNetStatus Purpose To retrieve information on 8...

Страница 141: ...on State 0 1 BT_DISCONNECTED BT_CONNECTED 7 int Signal RSSI Signal Level 10 6 6 5 over 5 Weak Moderate Strong 8 int Reserved 10 Reserved Null GetBTStatus Purpose To retrieve information on Bluetooth n...

Страница 142: ...or PAN DUN1 refers to Bluetooth DUN for connecting a modem DUN2 refers to Bluetooth DUN GPRS for activating a mobile s GPRS Index Remarks WLAN SPP DUN1 DUN2 PAN 0 WLAN_State 1 WLAN_Quality 2 WLAN_Sign...

Страница 143: ...hcpEnable 1 SetNetParameter void DhcpEnable P_DHCP_ENABLE if NetInit 0 printf Initialization Fail while CheckNetStatus NET_IPReady OSTimeDly 10 GetNetParameter void IP P_LOCAL_IP printf IP d d d d IP...

Страница 144: ...connection Syntax int Nclose int conno int conno the connection to be closed Example Nclose conno Description This routine closes a previously established connection The connection number conno is a...

Страница 145: ...ip 230 145 22 4 if conno Nopen remote_ip TCP IP Nportno 2000 0 0 printf Fail to connect to Host s r n remote_ip Description This routine is used for both active and passive opens The behavior is deter...

Страница 146: ...ilable to be read or until a timeout occurs The timeout can be adjusted using socket_rxtout The application can avoid this blocking behavior by using socket_hasdata to make sure there is data availabl...

Страница 147: ...e following cases Case 1 In TCP four packets have been sent but never get any ACK The protocol stack will try to resend the packets until it times out i e 8 seconds The application can avoid this situ...

Страница 148: ...relevant structures please refer to the header file for terminal specific library Connection oriented Protocol TCP For a connection oriented socket such as SOCK_STREAM it provides full duplex connect...

Страница 149: ...nal Specific Function Library 143 Connectionless Protocol UDP For a connectionless message oriented socket datagrams can be sent to and received from a specific connected peer using sendto and recvfro...

Страница 150: ...name int size_of_name listen_socket socket PF_INET SOCK_STREAM TCP if listen_socket 0 printf SOCKET allocation failed memset local_name 0 sizeof local_name local_name sin_family AF_INET local_name sin...

Страница 151: ...inal socket remains in the listening state and can be used in a subsequent call to this routine to provide additional connections Note that this is a blocking function This routine will not return unl...

Страница 152: ...an use getsockname to learn the address and port that has been assigned to it If it is other than 0 this routine will verify this information against the actual local IP address of the local terminal...

Страница 153: ...zeof name name sin_family AF_INET name sin_port htons 3000 phostent gethostbyname server1 Metrologic com tw if phostent printf Can not get IP from DNS server memcpy name sin_addr phostent h_addr_list...

Страница 154: ...flags arg is ignored F_SETFL Set descriptor status flags to arg Depending on the value of cmd it can take an additional third argument arg Return If successful it returns a non negative value dependi...

Страница 155: ...renced by name This routine gets the IP address of the specified host from DNS server The IP address of DNS server must be specified when calling SetNetConfig Or it can be automatically retrieved from...

Страница 156: ...if the buffer provided is too small Return If successful it returns 0 On error it returns 1 The global variable errno is set to indicate the error condition encountered See Also connect getsockname g...

Страница 157: ...ocket level Level at which the option resides SOL_SOCKET IPPROTO_TCP or IPPROTO_IP optname Socket option for which the value is to be retrieved optval Pointer to the buffer in which the value for the...

Страница 158: ...ed option is returned in the optval buffer The integer pointed to by optlen should originally contain the size of this buffer on return it will be set to the size of the value returned Return If succe...

Страница 159: ...ocket Purpose To provide controls on the I O mode of a socket Syntax int ioctlsocket int fildes int request Example Description This routine manipulates the underlying device parameters of special fil...

Страница 160: ...edged and queued pending acceptance by the accept process This routine is typically used by servers that can have more than one connection request at a time If a connection request arrives and the que...

Страница 161: ...socket The flags argument allows one of the following values MSG_OOB returns urgent data out of bound data MSG_PEEK returns data but do not remove it from buffer allowing it to be read again on subseq...

Страница 162: ...s MSG_OOB returns urgent data out of bound data MSG_PEEK returns data but do not remove it from buffer allowing it to be read again on subsequent calls If from is not a null pointer the source address...

Страница 163: ...he requested operation It returns the total number of ready descriptors in all the sets The descriptor sets are stored as bit fields in arrays of integers The following are provided for manipulating s...

Страница 164: ...outgoing data to a specified send buffer buf on a connected socket The flags argument allows one of the following values MSG_OOB sends urgent data out of bound data MSG_DONTROUTE sends data using dire...

Страница 165: ...g behavior by using socket_cansend to make sure there is data available before calling sendto The whole data may not be sent at one time Check the return value in case the send buffer overflows Return...

Страница 166: ...ation SO_REUSEADDR Enables local address reuse SO_KEEPALIVE Enables keep connections alive SO_DONTROUTE Enables routing bypass for outgoing messages SO_BROADCAST Enables permission to transmit broadca...

Страница 167: ...on encountered See Also closesocket socket Purpose To create a socket that is bound to a specific service provider Syntax SOCKET socket int domain int type int protocol domain Protocol family this sho...

Страница 168: ...the communication domain in which communication is to take place The allowed combination of type and protocol parameters are as follows type protocol SOCK_STREAM TCP Stream socket SOCK_DGRAM UDP Data...

Страница 169: ...turns the value of conversion Otherwise See Also ntohl htons Purpose To convert an unsigned short integer from host byte order to network byte order Syntax unsigned htons unsigned val unsigned val an...

Страница 170: ...order Return If successful it returns the value of conversion Otherwise See Also htonl ntohs Purpose To convert an unsigned short integer from network byte order to host byte order Syntax unsigned nto...

Страница 171: ...ways returns the port number See Also Nopen DNS_resolver Purpose To get the remote IP address by remote name Syntax int DNS_resolver const char remote_host char remote_ip const char remote_host remote...

Страница 172: ...len buf Nwrite conno buf strlen buf Description This function checks if the amount of data byte count specified by len can be written out immediately to the connection specified conno Return If okay i...

Страница 173: ...har ipaddr int conno connection number char ipaddr pointer to IP address returned Example unsigned char ip 4 socket_ipaddr conno ip printf Remote IP d d d d r n ip 0 ip 1 ip 2 ip 3 Description This fu...

Страница 174: ...function will send an empty packet to the remote end to avoid such problem TCP only Return If successful it returns 0 On error it returns a negative value See Also socket_noblock Purpose To set the co...

Страница 175: ...ve status for a connection Syntax int socket_rxstat int conno int conno connection number Example val socket_rxstat conno Description The function gets the receive status for a connection Return The r...

Страница 176: ...ets the socket status for a connection Return The return value can be one of the following ESTABLISHED 1 SYN_SENT 2 SYN_RECEIVED 3 LISTEN 4 CLOSING 5 See Also socket_rxstat socket_txstat socket_testfi...

Страница 177: ...socket_txstat conno Description The function gets the transmit status for a connection Return The return value can be one of the following S_PSH 0x01 push S_FIN_SENT 0x08 FIN has been sent S_FIN_ACKED...

Страница 178: ...tion DUN mode Only one device is listed for quick connection PAN mode Up to eight access points are listed for roaming purpose Once the pairing procedure is completed and the list is generated success...

Страница 179: ...character stands for the string of MAC ID The next property after MAC ID is Device Name which consists of up to 20 characters and ends with a delimiter code r The next property after Device Name is P...

Страница 180: ...o specify the first three fields Otherwise the PIN code field needs to be specified for generating Link Key Inquiry Inquiry is used to discover other Bluetooth devices within range BTInquiryDevice Pur...

Страница 181: ...intf Find d devices in range Result Rst BTPairingTest Info 0 BTSerialPort if Rst printf Pair OK else printf Pair Fail Description This routine tries to pair with one Bluetooth device with matching typ...

Страница 182: ...clude lib_ops h include ucos h static const MENU_ENTRY PAIRING_ENTRY static const MENU_ENTRY DEVICELIST_ENTRY MENU SPP_MENU 2 1 0 Bluetooth void PAIRING_ENTRY void DEVICELIST_ENTRY static const MENU_E...

Страница 183: ...luetooth device Once pairing successfully the MAC ID of this remote device will be updated to the Frequent Device List Return None See Also BTPairingTest FreqDevListMenu FreqDevListMenu Purpose To cre...

Страница 184: ...5 NetInit 5 Network Status Once the initialization process is done the status of the network status can be retrieved from the system It will be periodically updated by the system The application progr...

Страница 185: ...n for other useful functions Close a Connection Call Nclose to terminate a particular connection i e conno returned by Nopen when the application program does not use it any more Termination of Networ...

Страница 186: ...if com_eot 2 break OSTimeDly 4 Call write_com and read_com to transmit and receive data respectively Call com_eot to detect if connection is broken For example if com_eot 2 printf Connection break Cal...

Страница 187: ...of DUN GPRS must be specified Parameter Default Description Index P_ BT_GPRS_APNAME 20 Null Name of Access Point for Bluetooth DUN GPRS 32 Wedge Emulator The program Serial to Keyboard Converter is a...

Страница 188: ...de lib_opr h include ucos h static const int beep 32 5 0 0 main SetCommType 2 COMM_RF Add WEDGE_EMULATOR flag to open_com open_com 2 BT_SERIALPORT_SLAVE WEDGE_EmULATOR clr_scr gotoxy 0 0 printf Virtua...

Страница 189: ...scr gotoxy 0 0 printf Virtual Wedge gotoxy 0 1 printf gotoxy 0 2 printf Ready gotoxy 0 3 printf Press a key to start gotoxy 0 4 printf on_beeper beep while getchar OSTimeDly 4 while 1 if getchar SendD...

Страница 190: ...tures will be further discussed later in this section 3 14 1 File System On each terminal there is an on board SRAM for data memory This is the place where all the system parameters program variables...

Страница 191: ...en use the file handle to identify the file 3 14 5 Error Code A system variable fErrorCode indicates the result of the last file operation A value other than zero indicates error Note The error code c...

Страница 192: ...currently exist in the system read_error_code Purpose To get the value of the global variable fErrorCode Syntax int read_error_code void Example if read_error_code 2 puts File not exist n Description...

Страница 193: ...e of the file to be renamed char new_filename new file name desired Example if rename data1 text1 puts data1 is renamed n Description This routine changes the file name specified by the argument old_f...

Страница 194: ...ax int append int fd char buffer int count int fd file handle of the target DAT file char buffer pointer to a buffer where data is written to int count number of bytes to be written Example append fd...

Страница 195: ...itten to the file Writing of data starts at the end of file position and the file pointer position is unaffected by the operation This routine will automatically extend the file size to hold the data...

Страница 196: ...le error codes and their interpretation Error Code Interpretation 2 File specified by fd does not exist 4 File specified by fd is not a DAT file 7 Invalid file handle 8 File not opened 10 No free file...

Страница 197: ...le size automatically Return If successful it returns the number of bytes actually removed from the file On error it returns 1 An error code is set to the global variable fErrorCode to indicate the er...

Страница 198: ...AT file 7 Invalid file handle 8 File not opened See Also delete_top eof Purpose To check if the file pointer of a DAT file reaches the end of file Syntax int eof int fd int fd file handle of the targe...

Страница 199: ...7 Invalid file handle 8 File not opened lseek Purpose To reposition the file pointer of a DAT file Syntax long lseek int fd long offset int origin int fd file handle of the target DAT file long offset...

Страница 200: ...greater than zero used to identify the file for subsequent file manipulation on the file If the file specified by filename does not exist it will be created first If filename exceeds eight characters...

Страница 201: ...is set to the global variable fErrorCode to indicate the error condition encountered Below are possible error codes and their interpretation Error Code Interpretation 2 File specified by fd does not...

Страница 202: ...specified by fd does not exist 4 File specified by fd is not a DAT file 7 Invalid file handle 8 File not opened 9 The value of max_count is negative See Also read write writeln tell Purpose To get th...

Страница 203: ...omatically extend the file size to hold the data written The maximum number of characters that can be written is 32767 Return If successful it returns the number of bytes actually written to the file...

Страница 204: ...uring operation this routine will automatically extend the file size to hold the data written Return If successful it returns the number of bytes actually written to the file including the null charac...

Страница 205: ...u where the book is actually stored As you can see the books kept in the library are analogous to the data records stored in the DBF file and the various index entries are just its associate IDX files...

Страница 206: ...not a DBF file 7 Invalid file handle 8 File not opened 10 No free file space for adding members See Also create_DBF delete_member close_DBF Purpose To close a DBF file and its associated IDX files Syn...

Страница 207: ...th greater than member_len will be truncated to fit in User defined indexes may be created after the DBF file is created Return If successful it returns the file handle On error it returns 1 An error...

Страница 208: ...error codes and their interpretation Error Code Interpretation 2 File specified by DBF_fd does not exist 4 File specified by DBF_fd is not a DBF file 6 Cannot create file Because it is beyond the maxi...

Страница 209: ...er from a DBF file Syntax int get_member int DBF_fd int key_number char buffer int DBF_fd file handle of the target DBF file int key_number key no of the IDX file whose pointer points to the target me...

Страница 210: ...alue in an IDX file key_number which is associated to a DBF file DBF_fd If there is a complete match to the key_value the index pointer will point to the first of all matches In case there is more tha...

Страница 211: ...e value of origin can be one of the three values 1 the first index of IDX file 0 current index pointer position 1 the last index of IDX file Return If successful it returns the sequence number of offs...

Страница 212: ...le if fd open_DBF data1 0 puts data1 is opened n Description This routine opens a DBF file filename and gets the file handle of it A file handle is a positive integer greater than zero used to identif...

Страница 213: ...le if a report is to be generated by the sequence of date department and ID number and the date and department data may be repeated This can be done by rebuilding the ID number index first Then rebuil...

Страница 214: ...DBF_fd file handle of the associated DBF file int key_number key number of the IDX file to be deleted Example if remove_index DBF_fd 1 puts index is removed n Description This routine deletes an IDX...

Страница 215: ...lobal variable fErrorCode to indicate the error condition encountered Below are possible error codes and their interpretation Error Code Interpretation 2 File specified by DBF_fd does not exist 4 File...

Страница 216: ...e possible error codes and their interpretation Error Code Interpretation 2 File specified by DBF_fd does not exist 4 File specified by DBF_fd is not a DBF file 7 Invalid file handle 8 File not opened...

Страница 217: ...nk 0xF60000 0xF6FFFF for data storage such as the application settings The rest banks are available for storing user programs as well as font files Because the flash memory is non volatile it needs to...

Страница 218: ...yte See Also RamSize WriteFlash Purpose To write data to the flash memory Syntax int WriteFlash void target_addr void source_addr unsigned long size Example char szData 100 EraseSector 0xF60000 WriteF...

Страница 219: ...See Also RamSize init_free_memory Purpose To initialize the file space in SRAM Syntax void init_free_memory void Example init_free_memory Description This routine first tries to identify how many SRA...

Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...

Страница 221: ...s to suppress the download submenu For example DownLoadPage NO_MENU COMM_DIRECT BAUD_115200 In this case the terminal will be set to the Ready to download state without prompting the download submenu...

Страница 222: ...prc_menu MyMenu process MyMenu menu Description This routine creates a user defined menu SMENU and MENU structures are defined in the header files User can simply fill the MENU structure and call prc...

Страница 223: ...String Functions string h 222 4 4 Mathematical Functions math h 224 4 5 Utility Functions stdlib h 226 4 6 Diagnostics assert h 227 4 7 Variable Argument Lists stdarg h 227 4 8 Non Local Jumps setjmp...

Страница 224: ...se use proprietary Library routines Formatted Output Only sprintf is supported For formatted output to display refer to proprietary Library LCD Formatted Input Only sscanf is supported Character Input...

Страница 225: ...isdigit c is true isalpha c isupper c or islower c is true iscntrl c control character isdigit c decimal digit isgraph c printing character except space islower c lower case letter isprint c printing...

Страница 226: ...s ct n compare at most n characters of string cs with ct return valus 0 if cs ct return 0 if cs ct return 0 if cs ct char strchr cs c return pointer to first occurrence of c in cs or NULL if not prese...

Страница 227: ...cters from ct to s return s void memmove s ct n same as memcpy except that it works fine even if objects overlap int memcmp cs ct n compare first n characters of cs with ct return as strcmp void memch...

Страница 228: ...in the range radians sinh x hyperbolic sine of x cosh x hyperbolic cosine of x tanh x hyperbolic tangent of x exp x base e raised to the power of x log x log x x 0 log10 x log to the base 10 of x x 0...

Страница 229: ...double ip split x into its integer and fraction parts each with the same sign as x Returns the fractional part and loads the integer part into ip fmod x y the remainder of x y with the same sign as x...

Страница 230: ...double long strtol const char s char endp int base Convert the prefix of s to long unsigned long strtoul const char s char endp int base Convert the prefix of s to unsigned long int rand void Return...

Страница 231: ...e Argument Lists stdarg h Functions for processing variable arguments are listed below va_start va_list ap lastarg type va_arg va_list ap type void va_end va_list ap 4 8 Non Local Jumps setjmp h Not s...

Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...

Страница 233: ...to 32 tasks with priority set from 0 to 31 the lower number the higher priority for the user program The main task main takes priority 16 A task desiring the semaphore will perform a PEND operation A...

Страница 234: ...L must be used in pairs Return None See Also OS_ENTER_CRITICAL OSSemCreate Purpose To create and initialize a semaphore Syntax OS_EVENT OSSemCreate unsigned value where OS_EVENT a data structure to ma...

Страница 235: ...err is a pointer to a variable which will be sued to hold an error code OSSemPend sets err to either 1 OS_NO_ERR if the semaphore is available 2 OS_TIMEOUT if a timeout occurred Example OSSemPend Dis...

Страница 236: ...rpose To create a task Syntax unsigned char OSTaskCreate void task void pd void pdata unsigned char pstk unsigned long stk_size unsigned char prio where task is a pointer to the task s code pdata is a...

Страница 237: ...an ISR cannot delete a task This function will verify that you are not attempting to delete the C OS s idle task Return If successful it returns OS_NO_ERR If the task to be deleted does not exist it r...

Страница 238: ...232 C Programming Guide For Optimus S R...

Страница 239: ...190 close_com 102 close_DBF 200 closesocket 146 clr_eol 90 clr_icon 90 clr_kb 74 clr_rect 90 clr_scr 91 CodeBuf 39 CodeLen 39 CodeType 39 com_cts 109 com_eot 102 com_overrun 103 com_rts 109 connect 14...

Страница 240: ...57 InputPassword 32 ioctlsocket 153 IrDA_Timeout 25 K kbhit 75 KernelVersion 29 KEY_CLICK 25 KeypadLayout 29 L lcd_backlit 81 LibraryVersion 30 listen 153 LoadProgram 36 LockAlphaState 77 lseek 193 l...

Страница 241: ...ey 21 setsockopt 159 SetVideoMode 82 show_image 92 shut_down 21 shutdown 160 socket 161 socket_block 165 socket_cansend 166 socket_fin 166 socket_hasdata 167 socket_ipaddr 167 socket_isopen 167 socket...

Отзывы: