background image

SDK Programming Guide Version 1.511

 

ABLELink

R

 

Ethernet-Serial Server MAXI Series

 

           

 

        } 

        recv_f = _OK ; 

 

    //----- process receive data here 

    recv_cnt = cb->recvlen ; 

        recvbuf_ptr = ( unsigned char far *)cb->recvbuf ; 

 

    //----- response message 

    ret = tcp_send( cb->handle, "Hello, I receive data =", 24, send_post, NULL_ARG); 

    ret = tcp_send( cb->handle, recvbuf_ptr, recv_cnt, send_post, NULL_ARG); 

        ret = tcp_send( cb->handle, "\r\n", 2, send_post, NULL_ARG); 

 

        //----- request to receive next data 

    ret = tcp_receive( cb->handle, (unsigned char far *)recvbuf_ptr, DEF_MSS, recv_post, NULL_ARG); 

        if ( ret != SUCCESS ) { 

                connect_f = _ERR; 

        } 

 

void    _loadds far    connect_post( CMDBLK far *cb, void far *arg) 

        //----- check connect success or not 

        if( cb->retcode != SUCCESS ) { 

 

        return; 

        } 

    connect_f = _OK; 

 

        //----- request to receive data 

//      tcp_receive( cb->handle, (unsigned char far *)recvbuf, sizeof(recvbuf), recv_post, 0l ); 

 

void    _loadds far    listen_post( CMDBLK far *cb, void far *arg) 

        //----- check listen success or not 

        if( cb->retcode != SUCCESS ) { 

 

    connect_f = _ERR ; 

Copyright © 2004 Atop Technologies, Inc. 

All rights reserved. Designed in Taiwan. 

 

 

 

Summary of Contents for ABLELink GW21 MAXI Series

Page 1: ...TOP ABLELinkTM Serial Server GW21x MAXI Software Development Kit Programming Guide Version 1 511 Updated at 2004 05 14 ATOP Technologies Inc Tel 886 3 5508137 Fax 886 3 5508131 E mail service atop com tw ...

Page 2: ... disclosed transmitted stored in a retrieval system or translated into any human or computer language in any form by any means in whole or in part without the prior express written consent of Atop Technologies Inc Published by Atop Technologies Inc 2F No 146 Sec 1 Tung Hsing Rd Jubei City Hsinchu 302 Taiwan R O C Tel 886 3 5508137 Fax 886 3 5508131 www atop com tw Copyright 2004 Atop Technologies ...

Page 3: ...se harmful interference to radio communications Operation of this equipment in a residential area is likely to cause harmful interference in which case the user will be required to correct the interference at his own expenses A shielded type power cord is required in order to meet FCC emission limits and also to prevent interference to the nearby radio and television reception It is essential that...

Page 4: ...N PC 26 4 1 1 Simulation Introduction 26 4 1 2 Differences Between Serial Server and PC 26 4 2 DOWNLOAD MULTIPLE APPLICATION PROGRAMS 28 5 API OVERVIEW 30 5 1 SERIAL I O FUNCTIONS OVERVIEW 30 5 2 AUDIO LED FUNCTION OVERVIEW 31 5 3 DOS FUNCTION OVERVIEW 31 5 4 TCP IP FUNCTION OVERVIEW 31 5 5 MEMORY FUNCTION OVERVIEW 33 5 6 TIMER INTERRUPT HANDLING FUNCTION OVERVIEW 33 5 7 WATCH DOG TIMER OVERVIEW 3...

Page 5: ...T485TYPE 44 GETPORTTYPE 44 GETCONSOLESTA 44 GETNEWPORTTYPE 45 GETTOTALPORT 45 COM_CONFIG 46 COM_GETBUF 46 COM_PUTBUF 47 COM_CLEARRXQUE 48 COM_CLEARTXQUE 48 COM_TXQUEISEMPTY 48 COM_DTR_ACTIVE 49 COM_RTS_ACTIVE 49 COM_DSR_STATUS 50 COM_CTS_STATUS 50 BUZZERON 50 SETUPCOMLED 51 SETUPPROCESSLED 51 GETINTRVECTOR 52 SETINTRVECTOR 52 GETVERSION 53 SYSTEM_RESET 54 SETAPSERIALNO 54 GETAPSERIALNO 54 Copyrigh...

Page 6: ...UDP_SEND 64 UDP_RESET 65 GETLOCALIPADDR 66 GETLOCALETHADDR 66 GETDEFAULTGATEWAY 67 GETLOCALNETMASK 68 ERASESECTOR 68 PROGONEBYTE 69 PROGSTRING 70 READEEPROM 71 WRITEEEPROM 72 READMACEEPROM 72 WRITEMACEEPROM 72 WATCHDOGCTRL 73 CLRWATCHDOGTIME 73 SETUPWATCHDOGTIME 74 SETIOMODE 74 GETIOMODE 74 SETOUTSTATE 75 GETINSTATE 75 READRTCTIME 75 READRTCDATE 76 WRITERTCTIME 76 Copyright 2004 Atop Technologies ...

Page 7: ...NLY 83 GETNETWORKTYPE FOR GW51W MAXI ONLY 84 SETNETWORKTYPE FOR GW51W MAXI ONLY 84 GETTRANSMITRATE FOR GW51W MAXI ONLY 84 SETTRANSMITRATE FOR GW51W MAXI ONLY 85 GETXI300WEPFLAG FOR GW51W MAXI ONLY 85 SETXI300WEPFLAG FOR GW51W MAXI ONLY 86 GETXI300WEPBIT FOR GW51W MAXI ONLY 86 SETXI300WEPBIT FOR GW51W MAXI ONLY 87 GETXI300WEPKEY FOR GW51W MAXI ONLY 87 SET XI300WEPKEY FOR GW51W MAXI ONLY 87 GETRFREA...

Page 8: ...3 ERROR MESSAGES 94 APPENDIX C SAMPLE PROGRAM 98 C 1 TCP IP SAMPLE PROGRAM 98 C 2 SERIAL PORT SAMPLE PROGRAM 102 APPENDIX D CONFIGURATION UTILITY 105 D 1 RUN THE UTILITY 105 D 2 DETECTING OPERATIONAL CONTROLLERS AND DEVICES 106 D 3 CONFIGURING CONTROLLERS AND DEVICES 107 Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 9: ... applications it can function as a gateway between field devices and cell controller By using the RS 232 RS 485 ports it functions as a gateway between field bus and Ethernet The development toolkit is ATOP ABLELinkTM Embedded Serial Server SDK It contains a set of API library sample programs development utilities a download utility and a configuration utility You can develop an application progra...

Page 10: ...1 2 GW21x MAXI Front View There is a Evaluation Module that provides power connector RJ 45 connector of Ethernet D type 9 pin connector of RS 232 LEDs for GW21x MAXI to make you more easer to do testing on GW21x MAXI About detailed information please refer to GW21x MAXI User Manual This document describes how to develop an application been run in GW21x MAXI Copyright 2004 Atop Technologies Inc All...

Page 11: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Figure 1 2 GW21x MAXI Front View Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 12: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 13: ...form test on it The developing environment is as followings Development environment DOS Win95 Win98 NT Win Me Win2000 Simulation environment DOS Win95 Win98 Development tools Please see the following table Tool Vendor Remark MSC 6 00A MSC 7 X MSVC 1 X MicrosoftTM 16 bits Compiler note 1 MASM 5 X or later MicrosoftTM Locate Utility System Software Inc Serial Server API ATOPTM Serial Server Library ...

Page 14: ... 3 Installation OK You can now start creating your applications based on SDK sample program Note The host PC AP can use the standard MSC library but the ABLELinkTM Serial Server AP can only use the rebuilt MSC library resides for example in the C GW21S2 NEWLIB directory 2 3 ABLELinkTM SDK Package Content Directory File Name Descriptions BIN DAPTCPIP EXE TCP IP driver for MS DOS HOST CFG accessory ...

Page 15: ...ing operation or change the stack size please use the STARTUP2 obj to replace the STARTUP1 obj and then edit the stackf asm Note Update STACK_SIZE and FLOAT symbol in makefile are useless Please update stackf asm directly COMAPI OBJ advanced serial port API using hardware interrupt service routine to send and receive serial port data COMALO OBJ accessory file of COMAPI OBJ to tune the size of send...

Page 16: ...P a C TCP sample program in host side PC GW21_CMD R W flash memory sample program GW21_COM a serial port sample program GW21_COM2 a serial port sample program for RS485 2 wires GW21_CONNECT a TCP client sample program GW21_FUNC an API sample program include LED control get system time and watchdog control GW21_Listen4 a TCP server sample program 4 connections GW21_FLOAT a sample program to calcula...

Page 17: ...ramming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series DOWNLOAD BAT a batch file to download firmware to GW21x MAXI Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 18: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 19: ...tion program please install Microsoft C 6 0 or above 16 bits complier and GW21x MAXI SDK For more information you can refer chapter 2 The process flow of developing an application program is as following AP C ASM COMPILER Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan Al l AP OB MSC LIB LINK USERLOC CMD AP EXE AP OMF EXE2HEX XOH86 ...

Page 20: ...in directory To run the batch file may be like following 2 Append the SDK BIN directory to the system environment parameter PATH Then you can use SDK utilities in any directory Step 2 Write your application program You can write your application program by any text editor Step 3 Compile your application program After writing application program you can compile the program The C compiler option arg...

Page 21: ... series do not support to locate an execution file dynamically After linking to an execution file you must locate the execution file to the specified code segment and data segment to generate an OMF file For example exe2omf userloc cmd Note You can find the file userloc cmd from sample program And then using an utility to transfer the binary file format of OMF file to a text file format HEX file F...

Page 22: ...064K bytes Used by kernel reserved SRAM 0x10000 0x7FFFF 448K bytes Used by your AP data 0x80000 0xDFFFF 384K bytes Used by your AP code FLASH ROM 0xE0000 0xFFFFF 128K bytes Used by kernel reserved Table 2 1 Memory Partition of Serial Server After you have generated the user application programs in exe format and before downloading them to the Serial Server please do the following 1 Find the memory...

Page 23: ...of the userloc cmd unless you wish to download multiple APs to the Serial Server However this is not recommended 3 3 Process Flow of Serial Server Kernel The ABLELinkTM Serial Server kernel resides in the flash memory providing the following functions System Initialization including H W diagnosis Data Initialization Download Service Packet driver and TCP IP driver Subset of BIOS functions Subset o...

Page 24: ... before System Initialization After System Initialization the RUN LED will blink twice again The time interval is about 1 seconds Note After System Initialization User AP ok and Enable User AP the RUN LED will all blink twice Because the time intervals between them are too short we cannot identify each other but maybe only one The operational flow of the system is depicted in the following picture...

Page 25: ...Yes Clear memory No 1 RUN LED Blinking thrice System Initialization User AP OK Enable User AP Jump to User AP ENDLESS LOOP IDLE LOOP WAIT DOWNLOADING Yes No Yes No RUN LED Blinking twice RUN LED Blinking twice RUN LED Blinking twice RUN LED Blinking twice RUN LED Always On RUN LED Always Blinking Upon downloading GW21S 512 will suspend anything and Copyright 2004 Atop Technologies Inc All rights r...

Page 26: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 27: ...etween Serial Server and PC The Serial Server is not fully compatible with the PC in terms of operational functionalities The following section describes these differences Direction control of RS 485 transceiver PC Use RTS DTR signal Serial Server Use EnableRS485rx and EnableRS485tx API Please note that if you are sending receiving data through the API the Serial Server kernel will resolve the dif...

Page 28: ...l Server Only support followings INT10H Video Audio I O and Run LED functions This is like INT10H of DOS INT14H Serial I O functions This is like INT14H of DOS INT1CH Software timer interrupt every 55 ms This is like INT1CH of DOS Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 29: ...ownload one application program at a time For example you will do the following when downloading multiple application programs Application Memory Segment AP1 code segment 0x8000 data segment 0x1000 AP2 code segment 0xD000 data segment 0x1000 Note 1 The reasonable value of code segment is from 0x8000 to 0xD000 2 The reasonable value of data segment is 0x1000 3 The code and data segments cannot be o...

Page 30: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 31: ... serial port communication mode Set baud rate data bit parity and stop bit SendSerialData Send data to the serial port GetSerialData Receive data from the serial port GetSerialStatus Get serial line status EnableSerialHWintr Enable hardware interrupts of serial port DisableSerialHWintr Disable hardware interrupts of serial port EnableRS485rx Set the RS 485 transceiver to RX mode EnableRS485tx Set ...

Page 32: ...stablish up to 4 TCP connections with other nodes on the same local area network The TCP application program pays more attention on error recovering The maximum data length per packet must be less than 1460 bytes The UDP is an unreliable connectionless communication protocol Unlike TCP protocol the UDP application program pays more attention on the error handling of communication The Serial Server...

Page 33: ... Receive data from any node of network udp_receiveX Receive data from the specific node udp_send Send data to the destination node udp_reset Release all of the UDP ports There is one structure definition named CmdBlock in the header file tcpdef h Through this structure you can request the TCP IP s service either by TCP or UDP and examine the returned code The following structure elements are impor...

Page 34: ...String Write a block of data into flash memory ReadEEPROM Read one word from EEPROM WriteEEPROM Write one word into EEPROM WriteMacEEPROM Write IP address router address and netmask into EEPROM memory ReadMacEEPROM Read IP address router address and netmask from EEPROM memory 5 6 Timer Interrupt Handling Function Overview There are 3 types of timer interrupt in the GW21x MAXI the 1 ms 5 ms and 55 ...

Page 35: ...Dog Timer is cleared by AP ClrWatchDogTime Clear Watch Dog Timer SetupWatchDogTime Set the timeout period of the Watch Dog Timer Only for manual mode 5 8 Advanced Serial Port API in comapi obj There are some advanced serial port functions in comapi obj We use ISR Interrupt Service Routine to process data that are sent to or come from serial port The ISR is triggered by hardware interrupt so the pe...

Page 36: ...tus Get the status of CTS signal 5 9 Digital Input and Digital Output Overview The controller provides Digital Input and Digital Output functions These functions are useful to monitor or control GPIO channels There are 4 GPIO channels in controller Each channel can be configured to be DI channel or DO channel Function Descriptions SetIOMode Set a channel to be DI DO GetIOMode Get the channel s I O...

Page 37: ...ame and password 5 12 Wireless LAN Command Overview There functions are only for models with wireless LAN Function Descriptions GetESSID Get the Extended Service Set ID SetESSID Set the Extended Service Set ID GetFrame Get frame length used for RTS CTS handshake control SetFrame Set frame length used for RTS CTS handshake control GetFragment Get fragment length for unicast message transmission Set...

Page 38: ...s SetXI300WEPBit Set WEP bits GetXI300WEPKey Get WEP key SetXI300WEPKey Set WEP key GetRFRealChannel Get the RF channel when linking with Access Point GetRFTxRate Get the real transmission rate when linking with Access Point GetAPName Get the name of Access Point which linking with GetAPMac Get the MAC address of Access Point which linking with Copyright 2004 Atop Technologies Inc All rights reser...

Page 39: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 40: ... 10 7 bits 001 38400 01 ODD 1 2 11 8 bits 010 57600 11 EVEN 011 115200 100 1200 101 2400 110 4800 111 9600 Return Value Unsigned short High byte contain LSR Line Status Register Bit 7 Time out 0 No timeout 1 Send data timeout Bit 6 Transmission shift register empty Bit 5 Transmission holding register empty Bit 4 Break detect Bit 3 Framing error Bit 2 Parity error Bit 1 Overrun error Bit 0 Data rea...

Page 41: ...Register Bit 7 Time out 0 No time out 1 Send data Time out Bit 6 Transmission shift register empty Bit 5 Transmission holding register empty Bit 4 Break detect Bit 3 Framing error Bit 2 Parity error Bit 1 Overrun error Bit 0 Data ready Low byte contain Send_data Example Send data 0 0x30 to 1st port Line status SendSerialData 0 0 Remarks This function sends one character data out to the specific se...

Page 42: ... serial port GetSerialStatus Description Get serial line status Include DAPAPI H Usage ushort GetSerialStatus ushort port Input Parameters port serial port number of Serial Server 0 1st port Return Value Refer to InitSerialMode return value Example Get line status of 1st port Line_status GetSerialStatus 0 Remarks This function gets the line status of the specific serial port EnableSerialHWintr Des...

Page 43: ...SerialHWintr 0 Remarks Disable the H W interrupt of the specific serial port EnableRS485rx Description Include DAPAPI H Usage void EnableRS485rx ushort port Input Parameters port serial port number of Serial Server 0 1st port Return Value None Example Enable RX mode of the 1st serial port EnableRS485rx 1 Remarks Set the RS 485 transceiver to RX mode only of the specific serial port This function h...

Page 44: ...rial Server 0 1st port Return Value None Example Issue EOI command of 1st port SerialIntrEOI 1 Remarks Issue H W End Of Interrupt EOI command before terminating the ISR Interrupt Service Routine Set485type Description Set Com Port to RS 422 4 wire RS 485 2 wire Not supported for GW21x MAXI but for GW21L E Include DAPAPI H Usage void Set485type uchar Set_485type Input Parameters Set_485type bit 0 f...

Page 45: ... Bit 0 Com Port 1 0 RS 422 1 RS 485 Getporttype Description Get the type of COM RS 232 RS 485 Not supported for GW21x MAXI but for GW21L E Include DAPAPI H Usage ushort Getporttype void Input Parameters None Return Value unsigned short Example get_porttype Getporttype bit 0 for 1st port Remarks Get RS 232 RS 485 Bit 0 Com Port 1 0 RS 485 1 RS 232 GetConsoleSta Description Get the state of a jumper...

Page 46: ...e ushort Getnewporttype void Input Parameters None Return Value 0 RS232 1 RS485 2 wires 2 RS422 4 wires 3 Console mode 4 RS422 RS485 5 Unknown Example ushort port_type port_type Genewporttype Remarks GetTotalPort Description Get the count of serial ports Include DAPAPI H Usage ushort GetTotalPort void Input Parameters None Return Value 0 count of serial ports Example ushort port_count port_count G...

Page 47: ...parity 4 space parity iData Data bits 7 7 data bits 8 8 data bits iStop Stop bits 1 1 stop bit 2 2 stop bits Return Value 0 ok others parameters error Example com_port 0 0 COM1 ret Com_Config com_port 9600L 0 8 1 open com port 9600 n 8 1 if ret 0 com port open error Remarks Com_GetBuf Description Get data from receiving buffer automatically received by ISR Include comapi h Usage int Com_GetBuf int...

Page 48: ...api h Usage int Com_PutBuf int iport char buf int cnt Input Parameters iport serial port number of Serial Server 0 1st port buf a buffer for storing sent data cnt Size of buffer Return Value ret 0 sent buffer in ISR is not enough 0 put data to sent buffer is ok Example char buf 256 com_port 0 0 COM1 strcpy buf r nReceive data cnt strlen buf ret Com_PutBuf com_port buf cnt put data to com port if r...

Page 49: ...earTxQue Description Clear sending buffer Include comapi h Usage void Com_ClearTxQue int iport Input Parameters iport serial port number of Serial Server 0 1st port Return Value none Example com_port 0 0 COM1 Com_ClearTxQue com_port Remarks Com_TxQueIsEmpty Description heck sending buffer is empty or not Include comapi h Usage int Com_TxQueIsEmpty int iport Input Parameters iport serial port numbe...

Page 50: ...Input Parameters iport serial port number of Serial Server 0 1st port active 0 inactive 1 active Return Value none Example com_port 0 0 COM1 active 1 Com_DTR_Active com_port active Remarks Com_RTS_Active Description Control the RTS signal Include comapi h Usage void Com_RTS_Active int iport int active Input Parameters iport serial port number of Serial Server 0 1st port active 0 inactive 1 active ...

Page 51: ... inactive 0 active Example com_port 0 0 COM1 status Com_DSR_Status com_port Remarks Com_CTS_Status Description Get the status of CTS signal Include comapi h Usage int Com_CTS_Status int iport Input Parameters iport serial port number of Serial Server 0 1st port Return Value 0 inactive 0 active Example com_port 0 0 COM1 status Com_CTS_Status com_port Remarks BuzzerOn Description Make a buzzer on GW...

Page 52: ... 0 off 1 on Return Value None Example SetupComLed 0 1 com port1 led on SetupComLed 1 0 com port2 led off Remarks SetupProcessLed Description Set RUN LED to on off Include DAPAPI H Usage void SetupProcessLed uchar com_led Input Parameters run_led 0 off 1 on Return Value None Example SetupProcessLed 1 set RUN led on SetupProcessLed 0 set RUN led off Remarks This function and BuzzerOn function both c...

Page 53: ...he current vector entry point by GetIntrVector then set the vector to your own interrupt function with SetIntrVector The saved vector can be restored if needed System reserved interrupt vectors Vector Description 0x1C 1 18 second timer interrupt 0x7D 1ms timer interrupt 0x0C the 1st RS 232 RS 485 communication interrupt 0x0D the 2nd RS 232 RS 485 communication interrupt 0x80 0xFF reserved for your...

Page 54: ...se you must make sure that the function satisfies the requirements for an interrupt handle routine For example if the ISR is an assembler function it must be a far routine that returns with an IRET instead of a RET Refer to the example don t stay more time on interrupt routine GetVersion Description Gets the Serial Server F W version Include DAPAPI H Usage ushort GetVersion void Input Parameters N...

Page 55: ...tAPSerialNO termsrv1 0 Remarks 1 ap_version is a null terminated string with 30bytes maximum 2 The ap_version can be displayed on the tool of moniter exe GetAPSerialNo Description Get the AP version Include DAPAPI H Usage void GetAPSerialNo char buf Input Parameters buf buffer for getting the AP version The max buffer length is 30 bytes If the AP version string is less than 30 characters then it i...

Page 56: ... define GW_MODEL_LEN 16 Char buf GW_MODEL_LEN 1 GetGwModel buf Remarks buf must be a characters array of 17 bytes tcp_connect Description Establish a connection to a peer by client site Include tcpapi h tcpdef h Usage int tcp_connect int far handle unsigned short fromPort unsigned long toIPaddr unsigned short toPort farFUNC postfunc char far parg Input Parameters phandle the pointer of unique hand...

Page 57: ...rverPORT 0x4321 for client device ret tcp_connect int far handle clientPORT serverIP serverPORT postfunc arg if ret SUCCESS fatal error else wait until a connect post function for server device ret tcp_listen int far handle serverPORT postfunc arg if ret SUCCESS fatal error else wait until a listen post function Remarks This function is used by the client device to establish a connection with the ...

Page 58: ...mmand the connection will be established accordingly tcp_disconnect Description Disconnect the established connection Include tcpapi h tcpdef h Usage int tcp_disconnect int handle Input Parameters handle the unique handle of the established connection Return Value SUCCESS disconnect is successful others error please refer to the file tcpdef h Example Reconnect to the device of server site tcp_disc...

Page 59: ...n Value SUCCESS connect is successful others error please refer to the file tcpdef h Example send data via TCP and check the tcp_send function is successful or not int flag_result main flag_result 1 tcp_send handle 1234 4 send_post while flag_result 1 wait for result return flag_result send_post if cb retcode SUCCESS flag_result OK 0 else flag_result cb retcode 0 Remarks This function is used to s...

Page 60: ...def h Example receive data once the connection is established listen_post or connect_post if cb retcode SUCCESS tcp_receive handle buf len receive_post arg receive_post if cb retcode SUCCESS Process incoming data and then issue tcp_receive again tcp_receive handle buf len receive_post arg Remarks This function is used to get data from the remote site via the established connection The maximum data...

Page 61: ...r Return Value SUCCESS connect is successful others error please refer to the file tcpdef h Example expect to get 100 bytes data length form TCP driver char buf 512 short len len 100 if tcp_getdata handle buf short far len SUCCESS if len 0 Processing the incoming data else fatal error recover connection Remarks This function is almost the same as tcp_receive The difference between these two functi...

Page 62: ...mple Open an UDP channel with local port 0x1234 int handle short localport 0x1234 if udp_open int handle short localport SUCCESS open ok and return a unique handler else fatal error happened Remarks This function is used by the client and severs to establish an UDP communication channel udp_close Description Close an UDP communication channel Include tcpapi h tcpdef h Usage int udp_close int handl...

Page 63: ...e Include tcpapi h tcpdef h Usage int udp_receive int handle char far pbuf unsigned short len farFUNC postfunc void far parg handle the handle of the UDP channel created by udp_open postfunc entry point of the post function pbuf the pointer of receive buffer parg the pointer of arguments to pass to post function Input Parameters len data length Return Value SUCCESS successful others error the defi...

Page 64: ...sed to get data from ANY OTHER IP ADDRESS The maximum data length is 1460 bytes In the post function you can check whether this function is successful or not If successful then you can process the incoming data In the udp_receive post function you can issue udp_receive again udp_receiveX Description Receive data from the remote site Include tcpapi h tcpdef h Usage int udp_receive int handle short ...

Page 65: ...oteIP buf len recv_post arg processing incoming data Remarks This function is used to get data from the specific node and port number The maximum data length is 1460 bytes In the post function you can check whether this function is successful or not If successful then you can process the incoming data In the udp_receiveX post function you can issue udp_receiveX again udp_send Description Send data...

Page 66: ...remoteIP buf len processing Remarks This function is used to send data to the destination node The maximum data length is 1460 bytes udp_reset Description Release all of the UDP ports Include tcpapi h tcpdef h Usage int udp_reset Input Parameters Return Value SUCCESS successful others error the definition of ERROR number please refer to the file tcpdef h Example Close all of the UDP channels udp_o...

Page 67: ... address 10 0 52 100 buf 0 0x0a buf 1 0x00 buf 2 0x34 buf 3 0x64 Remarks This function is used to get the Serial Server local IP address Each Serial Server must have its own IP address to identify the node on the local network via TCP IP The IP address can be set by a keyboard GetLocalEthAddr Description Get the Serial Server s ETHERNET address Include tcpapi h tcpdef h Usage int GetLocalEthAddr c...

Page 68: ...way address Include tcpapi h tcpdef h Usage int GetDefaultGateway char far buf Input Parameters buf buffer to store the default gateway address Return Value SUCCESS successful others error the definition of ERROR number please refer to the file tcpdef h Example Get the Serial Server s default gateway IP address uchar buf 4 GetDefaultGateway buf assume default gateway IP address buf 0 0x0a 10 0 52 ...

Page 69: ...0 buf 1 0xFF buf 2 0xFF buf 3 0xFF Remarks This function is used to get the NET MASK value In the Serial Server a keyboard can be used to set the NET MASK value Each Serial Server has a default NET MASK value EraseSector Description Erase one sector of flash memory Include DAPAPI H Usage ushort EraseSector uchar sector_id Input Parameters sector_id sector id to be erase id sector range 0 0x8000 0x...

Page 70: ...into flash memory Input Parameters addr address of flash memory Note 1 The segment value of the address must be 64k boundary it means that the legal segment value is 0x8000 0x9000 or 0xD000 For GW21x MAXI only 0xC000 and 0xD000 are available For example the address D000 F000 is correct but DF00 0 is error 2 All addresses in flash memory can be written only one times If you want to write the second...

Page 71: ...to flash memory Include DAPAPI H Usage ushort ProgString ushort len uchar src uchar dest len byte count of data src source data address Input Parameters dest address of flash memory Note 1 The segment value of the address must be 64k boundary it means that the legal segment value is 0x8000 0x9000 or 0xD000 For GW21x MAXI only 0xC000 and 0xD000 are available For example the address D000 F000 is cor...

Page 72: ...marks This function is used to write a block of data with length len pointed by src into the flash memory started from dest ReadEEPROM Description Read one word from EEPROM Include DAPAPI H Usage ushort ReadEEPROM ushort id Input Parameters id word identifier address range 0 23 24 words Return Value one word data stored at the address of id on the EEPROM Example Read the 5th word data in the seria...

Page 73: ...etmask Include DAPAPI H Usage ushort ReadMacEEPROM ushort id Input Parameters id 10H 11H Read IP address 12H 13H Read router address 14H 15H Read netmask address Return Value The low high word of the IP address Router address and netmask depending on the parameter id Example Get IP address ReadMacEEPROM 0x10 ReadMacEEPROM 0x11 Remarks Read low high word of the IP address Router address and netmask...

Page 74: ...h 00h watch dog controls by system auto 01h watch dog controls by user oneself Return Value None Example WatchDogCtrl 0x00 System clears the timer every one second automatically WatchDogCtrl 0x01 User must clear the timer every one second Remarks Default the watch dog timer is control by system kernel ClrWatchDogTime Description clear watch dog timer Include DAPAPI H Usage void ClrWatchDogTime voi...

Page 75: ... timer Remarks When the watch dog timer is set to be controlled by user the AP must call ClrWatchDogTime function to clear watch dog timer before this timeout time is reached Otherwise the system will reset itself SetIOMode Description Set a channel to be DI DO Include g21s3api h Usage void SetIOMode uchar channel uchar mode Input Parameters channel 0 3 for channel 1 4 mode 0 DO 1 DI Return Value ...

Page 76: ...el 0 3 for channel 1 4 State 0 DO off 1 DO on Return Value None Example SetOutState 0 1 set channel 1 DO to be on SetOutState 0 0 set channel 1 DO to be off Remarks GetInState Description Get the DI DO channel s state on off Include g21s3api h Usage ushort GetInState uchar channel Input Parameters channel 0 3 for channel 1 4 Return Value 0 off 1 on Example state1 GetInState 0 get channel 1 DI DO s...

Page 77: ... Void Return Value RTC date week day month year with BCD format Example unsigned long Sys_Date Sys_Date ReadRTCDate if the Date is 2001 03 16 Friday then Sys_Date will be 0x05160301 Remarks WriteRTCTime Description Write the time to the RTC as system time Include DAPAPI H Usage void WriteRTCTime uchar hour uchar minute uchar second Input Parameters With BCD format hour 0x00 0x23 24hrs BCD format m...

Page 78: ...day BCD format Return Value None Example if set the date to 2001 03 16 F WriteRTCTime 0x01 0x03 0x16 0x05 Remarks EnableWRProtect Description Enable RTC write protect user can only read RTC but not write it Include DAPAPI H Usage void EnableWRProtect void Input Parameters void Return Value None Example EnableWRProtect Remarks DisableWRProtect Description Disable RTC write protect user can read and...

Page 79: ...d It is about 49 days After the max value it will count from 0 again GetTickTime Description Get a time interval from system startup It is by tick 55ms Include DAPAPI H Usage ulong GetTickTime void Input Parameters None Return Value a time interval from system startup It is by tick Example ULONG SYS_SEC sys_sec GetTickTime Remarks The max time interval is 2 32 1 tick It is about 2734 days about 7 ...

Page 80: ...e DAPAPI H Usage ushort AddAccount char name_pwd Input Parameters name_pwd a string including user name and password delimited with blank User name is maximum 6 characters Password is maximum 20 characters Both can not include blank characters Return Value 0 overflow already have 4 user name in system 1 the user name already exist it will change the password 2 add a new user name ok Example char n...

Page 81: ... error else ok Remarks VerifyAccount Description This function is to verify a user name and password Include DAPAPI H Usage ushort VerifyAccount char name_pwd Input Parameters name_pwd a string including user name and password delimited with blank Return Value 0 error ether user name not exist or password not correct 1 verify ok Example char namepwd 80 password 20 sprintf namepwd s s admin passwor...

Page 82: ...n Value None Example GetESSID buf Remarks buf must be a characters array of 32 bytes SetESSID for GW51W MAXI only Description Set the Extended Service Set ID Include DAPAPI H Usage void SetESSID uchar buf Input Parameters buf buffer for setting the extended service set ID Return Value None Example SetESSID buf Remarks buf must be a characters array of 32 bytes GetFrame for GW51W MAXI only Descript...

Page 83: ... DAPAPI H Usage void SetFrame uint frame_size Input Parameters Frame_size Return Value None Example SetFrame frame_size Remarks Frame_size value is from 0 3000 GetFragment for GW51W MAXI only Description Get fragment length for unicast message transmission Include DAPAPI H Usage uint GetFragment void Input Parameters None Return Value Fragment length Example GetFragment Remarks Default 2346 Copyri...

Page 84: ...value is from 256 2346 GetChannel for GW51W MAXI only Description Get communication channel number for BSS creation Include DAPAPI H Usage Uchar GetChannel void Input Parameters None Return Value Channel No Example GetChannel Remarks Default 3 SetChannel for GW51W MAXI only Description Set communication channel number for BSS creation Include DAPAPI H Usage void SetChannel uchar channel_no Input P...

Page 85: ...ure 3 Ad hoc Example GetNetWorkType Remarks Default 1 SetNetWorkType for GW51W MAXI only Description Set net connection control characteristics Include DAPAPI H Usage void SetNetWorkType uchar networktype Input Parameters Networktype 1 or 3 Return Value None Example SetNetWorkType networkrtype Remarks Network Type 1 InfraStructure 3 Ad hoc GetTransmitRate for GW51W MAXI only Description Get data r...

Page 86: ...ssion Include DAPAPI H Usage void SetTransmitRatee uchar transmit_rate Input Parameters Transmit_rate 1 2 3 4 8 or 15 Return Value None Example SetTransmitRate transmit_rate Remarks Transmit Rate 1 1Mb 2 2Mb 3 Auto 1 2 4 5 5Mb 8 11Mb 15 Full Auto GetXI300WEPFlag for GW51W MAXI only Description Get WEP flag Include DAPAPI H Usage ushort GetXI300WEPFlag void Input Parameters None Return Value WEP fl...

Page 87: ...meters WEP flag 0 1 2 3 4 Return Value None Example SetXI300WEPFlag wep_flag Remarks WEP flag 0 Disable WEP 1 use WEP 1 2 use WEP 2 3 use WEP 3 4 use WEP 4 GetXI300WEPBit for GW51W MAXI only Description Get WEP bits Include DAPAPI H Usage ushort GetXI300WEPBit void Input Parameters None Return Value WEP Bit 0 40 Bits 1 128 Bits Example Wep_bits GetXI300WEPBit Remarks Default 1 Copyright 2004 Atop ...

Page 88: ...WEPKey for GW51W MAXI only Description Get WEP Key Include DAPAPI H Usage void GetXI300WEPKey ushort id uchar buf Input Parameters Id No of WEP Key buf buffer for getting the WEP Key Return Value None Example GetXI300WEPKey ushort id uchar Remarks Set XI300WEPKey for GW51W MAXI only Description Set WEP Key Include DAPAPI H Usage void void SetXI300WEPKey ushort id uchar buf Input Parameters Id No o...

Page 89: ...Return Value RF channel 1 11 Example iGetRFRealChannel Remarks GetRFTXRate for GW51W MAXI only Description Get the real transmission rate when linking with Access Point Include DAPAPI H Usage int GetRFTxRate void Input Parameters None Return Value Transmit_rate 1 2 3 4 8 Example GetRFTxRate Remarks Transmit Rate 1 1Mb 2 2Mb 3 Auto 1 2 4 5 5Mb 8 11Mb GetAPName for GW51W MAXI only Description Get th...

Page 90: ...e Return Value None Example GetAPName uchar Remarks GetAPMac for GW51W MAXI only Description Get the MAC address of Access Point which linking with Include DAPAPI H Usage void GetAPName uchar buf Input Parameters buf AP mac address Return Value None Example GetAPName uchar Remarks Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 91: ...0 4800 1 0 1 2400 1 0 0 1200 0 1 1 115200 0 1 0 57600 0 0 1 38400 0 0 0 19200 Data Parity Table Bit 4 3 Parity 1 1 Even 0 1 Odd X 0 None X Don t care Stop Bit Table Bit 2 Number of stop bit 0 1 1 2 Data Length Table Bit 1 0 Number of data bit 1 1 8 1 0 7 0 1 N A 0 0 N A The default setting is 9600 n 8 1 Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 92: ...gramming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series The baud rate 9600 none parity 8 bit data 1 stop bit 0xe3H Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 93: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 94: ...CD or diskette along with the shipping package or can be obtained from ATOP s Web site Step 3 Prepare the download tool The utility program gwdl exe and its configuration file dapdl cfg can be found in the GW21x MAXI product CD or diskette or from ATOP s Web site Step 4 Edit the dapdl cfg file to fit your system and configurations The format of the file looks like the following Be sure to save you...

Page 95: ... the GW21x MAXI does not receive any upgrade data within 30 seconds during process the GW21x MAXI will restart itself automatically and the system remains intact 3 After the upgrading process is finished the GW21x MAXI will program the flash memory During programming the flash memory the GW21x MAXI will clear the corresponding memory and reset itself once an error occurs If everything is OK the GW...

Page 96: ...x file format Hex File Text Error Hex File Check Sum Error Hex File Format Error Hex File End of Record Error GW21x MAXI The GW21x MAXI ACK Start Address Error The GW21x MAXI Response Command Error Configuration file handshaking problem The GW21x MAXI ACK Length Error Remote IP not found Open configuration file failure Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 97: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 98: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 99: ...message and echo the received data For example Receiving a A then it will echo the message Hello I receive data A 4 If disconnected it will listen again automatically You can use the telnet utility to test this sample program include tcpdef h include tcpapi h include dapapi h define _OK 0 define _ERR 1 define DEF_MSS 512 define MY_PORT 0x1234 define NULL_ARG char far 0 int handle int connect_f _ER...

Page 100: ...program set AP version while 1 first_flag 1 connect_f _ERR ret tcp_listen int far handle MY_PORT listen_post 0 if ret SUCCESS fatal err for i 0 i 30000 i wait a moment for j 0 j 100 j continue try again while 1 when listening or after listen ok if first_flag 1 when listening if connect_f _OK listen ok first_flag 0 send a message after connecting ptr Hello this is GW21 series r n ret tcp_send handl...

Page 101: ...e connection ok you can do some thing here void _loadds far send_post CMDBLK far cb void far arg check send success or not if cb retcode SUCCESS connect_f _ERR r eturn send_f _OK void _loadds far recv_post CMDBLK far cb void far arg int ret recv_cnt unsigned char far recvbuf_ptr check receive success or not if cb retcode SUCCESS connect_f _ERR return Copyright 2004 Atop Technologies Inc All rights...

Page 102: ...ARG request to receive next data ret tcp_receive cb handle unsigned char far recvbuf_ptr DEF_MSS recv_post NULL_ARG if ret SUCCESS connect_f _ERR void _loadds far connect_post CMDBLK far cb void far arg check connect success or not if cb retcode SUCCESS return connect_f _OK request to receive data tcp_receive cb handle unsigned char far recvbuf sizeof recvbuf recv_post 0l void _loadds far listen_p...

Page 103: ...s 1 Open COM1 9600 n 8 1 2 After COM1 is opened echo a message Hello this is GW21 series 3 After receiving data it will prompt a message and echo the received data For example Receiving a A then it will echo the message Receive data A You can use the terminal utility to test this sample program include g21s3api h include comapi h void main int i com_port cnt int ret char buf 256 ptr SetAPSerialNo ...

Page 104: ...haking COM_RTS_Active com_port 1 set com port to be send ready for h w handshaking ptr Hello this is GW21 series r n Com_PutBuf com_port ptr strlen ptr send data to com port while 1 cnt 256 ret Com_GetBuf com_port buf cnt receive data from com port if ret 0 cnt ret ptr r nReceive data Com_PutBuf com_port ptr strlen ptr send data to com port Com_PutBuf com_port buf cnt send data to com port Copyrig...

Page 105: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 106: ...m all the functions they would need for the system D 1 Run the utility To start the program please double click the program under Windows 95 98 NT 2000 environment and following window appears Figure D1 Main window of monitor exe utility program Display Description The following table lists the functional descriptions for all the fields Field Name Field Descriptions Copyright 2004 Atop Technologie...

Page 107: ...ading tag Stands for IP address collision Possibly caused by duplicated IPs on the network Leading tag Stands for Mac address collision Possibly caused by duplicated Mac address on the network MAC Address Indicates the detected Ethernet MAC address of responding controller or device Gateway Indicates IP address of the TCP IP gateway Subnet Mask Indicates the TCP IP network mask OS Indicates the OS...

Page 108: ...ion 2 Select the controller you want to configure from the IP Address column Click on the Config button A configuration dialog box will popup Figure D2 Configuration dialog box 3 Fill in information in the box along with the Password for the device and click on Config it to save the change or Cancel to abort The default password is null You can press the reset key of product to reset password to t...

Page 109: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series modified Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Page 110: ...SDK Programming Guide Version 1 511 ABLELinkR Ethernet Serial Server MAXI Series Copyright 2004 Atop Technologies Inc All rights reserved Designed in Taiwan ...

Reviews: