Home

Intellio C218Turbo/PCI User`s Manual

image

Contents

1. setsockopt Establish a connection to a peer include lt sdksock h gt int connect int s SOCKADDR name int namelen s A descriptor identifying an unconnected socket name The name of the peer to which the socket is to be connected namelen The length of the name This function is used to create a connection to the specified foreign association The parameter s specifies an unconnected datagram or stream socket If the socket is unbound unique values are assigned to the local association by the system and the socket is marked as bound Note that if the address field of the name structure is all zeroes connect will return the error EADDRNOTAVAIL For stream sockets type SOCK STREAM an active connection is initiated to the foreign host using name an address in the name space of the socket When the socket call completes successfully the socket is ready to send receive data For a datagram socket type SOCK DGRAM a default destination is set which will be used on subsequent send and recv calls Return Value Error Codes See Also If no error occurs connect returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values On a blocking socket the return value indicates success or failure of the connection attempt On a non blocking socket if the return value is 1 an application should check the errno If this indicates an error code of EINPROGRE
2. MSG OOB Send out of band data SOCK STREAM only If no error occurs sendto returns the total number of characters sent note that this may be less than the number indicated by len Otherwise it returns 1 and the global variable errno contains one of the following values EFAULT The buf or to parameters are not part of the user address space or the fo argument is too small less than the size of a SOCKADDR ENOBUFS The system had insufficient resources to perform the operation ENOTCONN The socket is not connected SOCK STREAM only EBADF The descriptor is not a socket EOPNOTSUPP MSG OOB was specified but the socket is not of type SOCK STREAM ESHUTDOWN The socket has been shutdown it is not possible to sendto on a socket after shutdown has been invoked with how set to 1 or 2 EWOULDBLOCK The socket is marked as non blocking and the requested operation would block EINVAL The socket has not been bound with baind recv recvfrom socket send setsockopt syntax Arguments Description Set a socket option include lt sdksock h gt int setsockopt int s int level int optname char optval int optlen s A descriptor identifying a socket level The level at which the option is defined the only supported level is SOL_SOCKET optname The socket option for which the value is to be set optval A pointer to the buffer in which the value for the requested option is supplied o
3. NOTE There are several types of function calls that must not be used in programs for NPort 4511 They are System I O such as printf System Interrupt open System Memory Allocate malloc 4 2
4. recv Syntax Arguments Description Receive data from a socket include lt sdksock h gt int recy int s char buf int len int flags s A descriptor identifying a connected socket buf A buffer for the incoming data len The length of buf flags Specifies the way in which the call is made This function is used on connected datagram or stream sockets specified by the s parameter and is used to read incoming data For sockets of type SOCK_STREAM as much information as is currently available up to the size of the buffer supplied is returned For datagram sockets data is extracted from the first enqueued datagram up to the size of the buffer supplied If the datagram is larger than the buffer supplied the buffer is filled with the first part of the datagram and the excess data is lost If no incoming data is available at the socket the recv call waits for data to arrive unless the socket is non blocking In this case a value of 1 is returned with the error code set to EWOULDBLOCK The select calls may be used to determine when more data arrives If the socket is of type SOCK_STREAM and the remote side has shut down the connection gracefully or the connection has been reset a recv will complete immediately with 0 bytes received flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket That is the semantics of this function are d
5. Bit 1 S DSR Bit2 S_ RI Bit3 S_CD SIO BADPORT Port was not open in advance sio_modem_irq Syntax Arguments Description Return Value sio_ofree Syntax Arguments Description Return Value sio_open Syntax Arguments Description Return Value 3 12 Set an event service routine for Event Control the case when the line status is changed include lt sdksio h gt int sio_modem_irq int port void func int port port Async serial port number func event service routine entry If the func is NULL it will disable this routine Set an event service routine for the case when the line status has changed When line status CTS DSR CD RI changes the system will call the event service routine SIO_OK OK SIO_BADPORT Port was not open in advance Get the length of free space in the Port Status driver s output buffer include lt sdksio h gt long sio_ofree int port port Async serial port number Get the length of free space in the driver s output buffer gt 0 free space in output buffer bytes SIO_BADPORT Port was not open in advance Enable a serial port for data Port Control transmitting receiving include lt sdksio h gt int sio_open int port port Async serial port number for NPort 4511 is always 1 Enable a serial port for data transmitting receiving After calling sio open the initial status of this COM port is the same as the last setting or configuration setting gt 0 Op
6. SIO BADPORT Port was not open in advance Data Input SIO NODATA SIO BADPARM No data to read Bad parameter Get the serial port s hardware and Port Status software flow control settings include lt sdksio h gt int sio getflow int port port Async serial port number Get the serial port s hardware and software flow control settings See the sio_flowctrl function gt 0 bit0 ICTS flow contro bitl RTS flow control bit2 Tx XON XOFF flow control bit3 Rx XON XOFF flow control SIO_BADPORT Port was not open in advance 3 7 sio_getmode Get the serial ports mode settings Port Status Syntax include lt sdksio h gt int sio_getmode int port Arguments port Async serial port number Description Get the serial port s mode settings Refer to the description of sio_ioctl to see the mode settings Return Value gt 0 mode see sio_ioctl SIO_BADPORT Port was not open in advance sio_GetReadTimeouts Get timeout values for Data Input sio_read and sio_getch Syntax include lt sdksio h gt int sio GetReadTimeouts int port DWORD TotalTimeouts DWORD IntervalTimeouts Arguments port Async serial port number TotalTimeouts Total timeout values Interval Timeouts Interval timeout values Description Get timeout values for sio_read and sio getch Return Value SIO_OK OK SIO_BADPORT Port was not open in advance sio_GetWriteTimeouts Get timeout values for Data Output sio_write and sio_putch Syntax include lt sdksio h g
7. Send data on a connected socket include lt sdksock h gt int send int s const char buf int len int flags s A descriptor identifying a connected socket buf A buffer containing the data to be transmitted len The length of the data in buf flags Specifies the way in which the call is made send is used on connected datagram or stream sockets and is used to write outgoing data on a socket For datagram sockets care must be taken not to exceed the maximum IP packet size of the underlying subnets Note that the successful completion of a send does not indicate that the data was successfully delivered If no buffer space is available within the transport system to hold the data to be transmitted send will block unless the socket has been placed in a non blocking I O mode On non blocking SOCK_STREAM sockets the number of bytes written may be between 1 and the requested length depending on buffer availability on both the local and foreign hosts The select call may be used to determine when it is possible to send more data Flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket That is the semantics of this function are determined by the socket options and the flags parameter The latter is constructed by or ing any of the following values Value Meaning MSG_00B Send out of band data If no error occurs send returns the total number of
8. len buffer length Receives data from a connected socket gt 0 received data length 1 error handle number 2 error argument 3 TCP not connected Sends data on a connected socket include lt sdknet h gt int tep send int handle char buffer int len handle the value return from tcp_open buffer the send out data buffer pointer len data length Sends data on a connected socket gt 0 send out data length 1 error handle number 2 error argument 3 TCP not connected 3 57 tcp_state Syntax Arguments Description Return Value udp_close Syntax Arguments Description Return Value udp iqueue Syntax Arguments Description Return Value 3 58 Get TCP state include lt sdknet h gt int tcp_state int handle handle the value returned from tcp_open Get TCP state 0 TCP closed 1 TCP listen 2 TCP connecting 3 TCP connected 4 TCP close wait remote closed 5 TCP closing 1 error handle 2 This handle is not a TCP handle Close a local UDP port Finclude lt sdknet h gt int udp close int handle handle The value return from udp_open Close a local UDP port 0 close OK 1 error handle number Get the size of data accumulated in UDP driver s input buffer include lt sdknet h gt int udp_iqueue int handle handle the value returned from udp open Get the size of data accumulated in UDP driver s input buffer gt 0 UDP input buffer
9. ooonccconcccccnaoconcnnancrananaconananonos 4 1 1 Overview The purpose of this Moxa PCG API Reference is to give MOXA PCG Programmable Communication Gateway programmers a complete reference guide to the various function calls that are available You may also refer to the companion guide MOXA Programmable Communication Gateway Programmer s Guide API stands for Application Programming Interface which includes necessary function calls and linking libraries Moxa API Quick Reference The SDK API functions are displayed in the format shown below Function Name Brief function introduction Function Attributes Language Format Syntax include header file name gt Function call Arguments Variable names Brief description of variables Description Detailed function call description Return Value Return Code 1 Description of return code Return Code 2 Description of return code To give you a specific example we show here the function sio_oqueue which is from the SDK API Serial 1 O library This function reports the amount of data that is waiting to be transmitted out through the serial port sio oqueue Get the length of data in both the system s Port output buffer and the driver s output buffer Status C Format Syntax include lt sdksio h gt long sio_oqueue int port Arguments port Async serial port number Description Get the length of data not yet sent out in both the system s output buffer and the
10. Internet addresses are returned in network order bytes ordered from left to right Internet Addresses Values specified using the notation take the following forms a b c d When four parts are specified each is interpreted as a byte of data and assigned from left to right to the four bytes of an Internet address Note that when an Internet address is viewed as a 32 bit integer quantity on the Intel architecture the bytes referred to above appear as d c b a That is the bytes on an Intel processor are ordered from right to left Note The following notations are only used by Berkeley and nowhere else on the Internet In the interests of compatibility with their software they are supported as specified Return Value See Also inet_ntoa Syntax Arguments Description Return Value See Also If no error occurs inet_addr returns an unsigned long containing a suitable binary representation of the Internet address given If the passed in string does not contain a legitimate Internet address for example if a portion of an a b c d address exceeds 255 inet_addr returns the value INADDR ANY inet ntoa Convert a network address into a string in dotted format include lt sdksock h gt char inet ntoa unsigned long in in An Internet host address This function takes an Internet address specified by the in parameter It returns an ASCII string representing the address in nota
11. bit 0 CTS flow control bit 1 RTS flow control bit 2 Tx XON XOFF flow control bit 3 Rx XON XOFF flow control 0 OFF 1 ON Set the hardware and or software flow control SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter Flush the driver s input output Port Control buffer include lt sdksio h gt int sio_flush int port int func port Async serial port number func flush action 0 flush input buffer 1 flush output buffer 2 flush input amp output buffer Flush the driver s input output buffer The data will no longer exist SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter sio_getbaud Syntax Arguments Description Return Value sio_getch Syntax Arguments Description Return Value sio_getflow Syntax Arguments Description Return Value Get the serial port s baud rate setting Port Status include lt sdksio h gt long sio_getbaud int port port Async serial port number Get the serial port s baud rate setting The return value is the actual baud rate For example a return value of 9600 means 9600 bps whereas 200 means 200 bps gt 0 the actual baud rate SIO_BADPORT Port was not open in advance Read one character from the driver s input buffer include lt sdksio h gt int sio_getch int port port Async serial port number Read one character from the driver s input buffer 0to255 The ASCII code of the character received
12. characters sent note that this may be less than the number indicated by len Otherwise it returns 1 and the global variable errno contains one of the following values 3 41 Error Codes See Also 3 42 EFAULT ENOTCONN EBADF EOPNOTSUPP ESHUTDOWN EWOULDBLOCK EFBIG The buf argument is not in a valid part of the user address space The socket is not connected The descriptor is not a socket MSG OOB was specified but the socket is not of type SOCK STREAM The socket has been shut down it is not possible to send on a socket after shutdown has been invoked with how set to 1 or 2 The socket is marked as non blocking and the requested operation would block Data written exceeds system capacity recv recvfrom socket sendto sendto Syntax Arguments Description Send data to a specific destination include lt sdksock h gt int sendto int s char buf int len int flags SOCKADDR to int tolen s A descriptor identifying a socket buf A buffer containing the data to be transmitted len The length of the data in buf flags Specifies the way in which the call is made to An optional pointer to the address of the target socket tolen The size of the address in to sendto is used on datagram or stream sockets and is used to write outgoing data on a socket Note that the successful completion of a sendto does not indicate that the data was successfully delivered se
13. driver s output buffer Return Value gt 0 length of data in bytes still remaining in the driver s output buffer SIO BADPORT Port was not open in advance 1 2 2 SDK API Overview SDK stands for Software Development Kit and includes not only the SDK APIs but also SDK Utilities the Windows utility used by the programmer to communicate with PCG plus several detailed example programs You may also refer to the companion guide MOXA Programmable Communication Gateway Programmer e Guide for additional information about using the utility In order to make the SDK library easier to use the function calls are divided into six groups based on their attributes The six groups are Serial I O API BSD Socket API Simplified Socket API System Control API Flash ROM Access APL and Debug API By keeping these 6 groups of APIs in mind programmers can more easily program the PCG to meet the needs of their application and set up the PCG to operate as needed In this chapter we give a brief introduction to all function calls for each of the six groups so that programmers can get a good overview of all of the APIs For detailed usage of each API refer to the following six sections e Serial I O API Overview e BSD Socket API Overview e Simplified Socket API Overview e System Control API Overview e Flash ROM Access API Overview e Debug API Overview Serial UO API In this section we categorize the serial I O library routi
14. if an XOFF character has been received include lt sdksio h gt int sio_ActXoff int port port Async serial port number This function causes transmission to act as if an XOFF character has been received SIO OK OK SIO_BADPORT Port was not open in advance This function causes transmission to Misc act as if an XON character has been received include lt sdksio h gt int sio_ActXon int port port Async serial port number This function causes transmission to act as if an XON character has been received SIO_OK OK SIO_BADPORT Port was not open in advance Set baud rate using the actual speed value include lt sdksio h gt int sio baud int port long speed port Async serial port number speed true baud rate e g 200 1200 9600 19200 Set baud rate using the actual speed value SIO OK OK SIO BADPORT Port Control Port was not open in advance sio_break Syntax Arguments Description Return Value sio break ex Syntax Arguments Description Return Value sio break irq Syntax Arguments Description Return Value Send out a break signal Misc include lt sdksio h gt int sio break int port int time port Async serial port number time break time in tics 1 18 2 second This function will block until the time has expired SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter Send out a break signal Misc include lt sdksio h gt int s
15. queued data size 1 error handle number 2 this is not a UDP handle udp_ofree Syntax Arguments Description Return Value udp_open Syntax Arguments Description Return Value udp recv Syntax Arguments Description Return Value Size of free space in UDP driver s input buffer include lt sdknet h gt int udp ofree int handle handle the value returned from udp open Size of free space in UDP driver s input buffer gt 0 UDP output buffer free size 1 error handle number 2 this is not a UDP handle Open a local UDP port include lt sdknet h gt int udp open int port port the local UDP port number Open a local UDP port gt 0 open handle 1 open fail Receives data from a specific source address include lt sdknet h gt int udp_recv int handle u_long rip int rport char buf int len handle the value return from udp_open rip recv from host IP address pointer rport recv from host UDP port number pointer buf recv data buffer pointer len recv data buffer length Receives data from a specific source address gt 0 recv data length 1 recy failed 3 59 udp_send Syntax Arguments Description Return Value 3 60 Sends data to a specific destination include lt sdknet h gt int udp_send int handle u_long rip int rport char buf int len handle the value returned from udp_open rip send to host IP address rport send to host UDP po
16. socket in a state where it is listening for an tcp listen nowait 8 incoming connection no walt tep listento nowait Listen for a specific incoming connection no wait Open a local UDP por Close local UDE part 2 7 Data Input Output This category includes functions to read data from the socket Socket Status Inquiry This category includes functions to query the communication status of the socket Size of free space in the TCP driver s input buffer itn ee Get the size of data accumulated in the TCP H driver s input buffer Get connected host IP and port Get TOP stare Size of free space in the UDP driver s input buffer aos Get the size of data accumulated in the UDP H driver s input buffer Port Status Inquiry This category includes functions to open TCP sockets and set and retrieve communication parameters 2 8 System Control API This section presents the system information library routines and gives a brief description of each routine For a more detailed description of these routines see Section 3 4 You should also note that the header file sdksys h must be included in your source code when calling these functions see the example source code for details of how to include a header file Description Read the server s time in seconds measured from power up Read the server s time in milliseconds measured from power up Task sleep time milliseconds sys timeout Set the
17. unsigned long value with HEX format for debugging dbg put IPQ Print out an IP address with the a b c d format for debugging dbg put sting Print out a string for debugging 2 10 3 SDK API Reference 3 1 Serial UO Library Reference sio_AbortRead Syntax Arguments Description Return Value sio_AbortWrite Syntax Arguments Description Return Value Abort when blocked from reading a Data Input block of data for sio_read and sio_getch include lt sdksio h gt int sio_AbortRead int port port Async serial port number Abort when blocked from reading a block of data for sio_read and sio getch Calling this function will cause sio_read to return immediately with return code of length of data read SIO_OK OK SIO BADPORT Port was not open in advance Abort when blocked from writing a Data Output block of data for sio_write and sio_putch include lt sdksio h gt int sio_AbortWrite int port port Async serial port number Abort when blocked from writing a block of data for sio_write or sio_putch Calling this function will cause sio_write to return immediately with return code SIO_ABORT_WRITE SIO_OK OK SIO_BADPORT Port was not already open sio_ActXoff Syntax Arguments Description Return Value sio Act Xon Syntax Arguments Description Return Value sio baud Syntax Arguments Description Return Value 3 2 This function causes transmission to Misc act as
18. A only User just can use 0x00000000 to Ox7FFFFFFF Your application starts to run to need first to call it N A N A Set async port interface signal type include lt sdksys h gt sys_set_SerialType int port int type port Async serial port number 0 RS 232 1 RS 422 2 RS 485 2w 3 RS 485 4w Note Not supported by NPort 4511 Set async port interface signal type 0 Set OK 1 Bad port 2 Bad parameter Cannot set this interface type 3 65 sys_sleep_ms Syntax Arguments Description Return Value See Also sys_timeout Syntax Arguments Description Return Value See Also 3 66 Task sleep time milliseconds include lt sdksys h gt int sys sleep ms long fime ms time ms Task sleep time in milliseconds Task sleep time milliseconds This function always returns 0 sys clock s sys clock ms Set the timeout event service routine include lt sdksys h gt int sys timeout void func long time ms func The timeout event service routine time_ms Timeout value in milliseconds Set the timeout event service routine 0 No errors EINVAL The isr argument event function pointer is invalid ENOBUFS No resources sys clock s sys clock ms sys sleep ms sys_event_suspend Syntax Arguments Description Return Value See Also Suspend interrupt include lt sdksys h gt void sys event suspend int type u long args type interrupt type 0 gt
19. ADF The descriptor is not a socket setsockopt socket htonl Syntax Arguments Description Return Value See Also htons Syntax Arguments Description Return Value See Also Convert an unsigned long from host to network byte order include lt sdksock h gt u long htonl u_long hostlong hostlong A 32 bit number in host byte order This routine takes a 32 bit number in host byte order and returns a 32 bit number in network byte order htonl returns the value in network byte order htons ntohl ntohs Convert an unsigned short from host to network byte order include lt sdksock h gt u short htons Cu short hostshort hostshort A 16 bit number in host byte order This routine takes a 16 bit number in host byte order and returns a 16 bit number in network byte order htons returns the value in network byte order htonl ntohl ntohs 3 29 inet_addr Syntax Arguments Description 3 30 Convert a string containing a dotted address into an in_addr include lt sdksock h gt unsigned long inet_addr char cp cp A character string representing a number expressed in the Internet standard notation This function interprets the character string specified by the cp parameter This string represents a numeric Internet address expressed in the Internet standard notation The value returned is a number suitable for use as an Internet address All
20. Arguments Description Return Value tep ofree Syntax Arguments Description Return Value ICH open Syntax Arguments Description Return Value 3 56 include lt sdknet h gt int tep listento nowait int handle u long rip int rport handle the value returned from tcp_open rip remote host IP address that user wants to link to 0 indicates don t case remote IP address rport remote host s TCP port No 0 indicates don t case the TCP port number Listen for a specific incoming connection no wait 0 start to listen 1 error handle number 2 this handle was opened by tcp_open 3 error state already connected Size of free space in TCP driver s input buffer include lt sdknet h gt int tcp_ofree int handle handle the value returned from tcp_open Size of free space in TCP driver s input buffer gt 0 TCP output buffer s free size 1 error handle number 2 This is not a TCP handle 3 TCP not connected Open a local TCP port include lt sdknet h gt int tep_open int port port local TCP port number Open a local TCP port gt 0 open handle 1 open fail tcp_recv Syntax Arguments Description Return Value tep send Syntax Arguments Description Return Value Receives data from a connected socket include lt sdknet h gt int tcp_recv int handle char buffer int len handle the value returned from tcp_open buffer the receiveed data buffer pointer
21. NPort Programmable Communication Gateway API Reference Second Edition April 2003 Moxa Technologies Co Ltd e y a 5 Tel 866 2 8919 1230 T Fax 886 2 8919 1231 y P www moxa com MOXA support moxa com tw MOXA PCG API Reference The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement Copyright Notice Copyright O 2003 Moxa Technologies Co Ltd All rights reserved Reproduction without permission is prohibited Trademarks MOXA is a registered trademark of Moxa Technologies Co Ltd All other trademarks or registered marks in this manual belong to their respective manufacturers Disclaimer Information in this document is subject to change without notice and does not represent a commitment on the part of Moxa Moxa provides this document as is without warranty of any kind either expressed or implied including but not limited to its particular purpose Moxa reserves the right to make improvements and or changes to this manual or to the products and or the programs described in this manual at any time Information provided in this manual is intended to be accurate and reliable However Moxa Technologies assumes no responsibility for its use or for any infringements on the rights of third parties that may result from its use This product might include unintentional technical or typographical error
22. PP The socket is not of type SOCK_STREAM EFAULT The pointer in argument is invalid EWOULDBLOCK The socket is marked non blocking and no connections are waiting to be accepted EFILE The initial system file table is full bind connect listen select socket Associate a local address with a socket include lt sdksock h gt int bind int s SOCKADDR name int namelen s A descriptor identifying an unbound socket name The address to assign to the socket namelen The length of the name This routine is used on an unconnected datagram or stream socket before subsequent connect s or listen s When a socket is created with socket it exists in a name space address family but it has no name assigned bind establishes the local association host address port number of the socket by assigning a local name to an unnamed socket 3 19 Return Value Error Codes See Also 3 20 In the Internet address family a name consists of several components For SOCK_DGRAM and SOCK_STREAM the name consists of three parts a host address the protocol number set implicitly to UDP or TCP respectively and a port number which identifies the application If an application does not care what address is assigned to it it may specify an Internet address equal to INADDR_ANY a port equal to 0 or both If the Internet address is equal to INADDR_ANY any appropriate network interface will be used this simplifies a
23. SS then your application can use select to determine the completion of the connection request by checking if the socket is writeable EINPROGRESS TCP only The socket is nonblocking and a connection attempt would block EADDRNOTAVAIL The specified address is not available EADDRINUSE The specified address already in use ECONNREFUSED TCP only The attempt to connect was forcefully rejected by the remote machine EISCONN The socket is already connected EBADF The descriptor is not a socket ETIMEDOUT TCP only Attempt to connect timed out without establishing a connection Current time out value is 30 seconds accept bind getsockname socket select 3 23 gethostbyname Syntax Arguments Description Return Value See Also 3 24 Get host information corresponding to a hostname include lt sdksock h gt struct hostent gethostbyname char name name A pointer to the name of the host gethostbyname returns a pointer to the following structure which contains the name s and address which correspond to the given address struct hostent char h_name char h aliases short h_addrtype short h_length char h addr list D The members of this structure are Element Usage h_name server name of local system h_aliases A NULL terminated array of alternate names unused currently h_addrtype The type of address being returned this is always AF_INET h_length The lengt
24. UC ee lan Rae sat 3 54 top ste a a Det Aa 3 54 tep listen NM e tn 3 55 tep listento iii 3 55 tcp listento mowait eeen 3 56 tep SR RA 3 56 Ion Open dd a leeks 3 56 TOPSTOCV kn at bi es abla st 3 57 A EENS 3 57 e in anita 3 58 dl iii da 3 58 Up QUEUE A a 3 58 Oh eet 3 59 O 3 59 Oe 3 59 O RSA TS RS RS TR 3 60 3 4 System Control Library Reference eeen 3 61 Sys CLOCK A ara ss 3 61 SVS GLOCK Ss A 20 3 61 sys disable watchdog ene err 3 61 sys enable watchdog era 3 62 SSK A I nk alli seta a satel a 3 62 E e a ra A 3 63 sys get SerialT ype eee ceccssecssecsecseecseeeeeeeeeeeeeeeeeeeseeesereees 3 64 sys get WatchdogStatus ooocooonoccnononoccconocononononncnn nono nonnnnnnonnnnnos 3 64 Sys restart YM aid 3 64 sys restart USE AP inicia ai 3 65 Sys Set Register Disil si diesen fa 3 65 sys set Serial Type rt 3 65 AE Benn a AN 3 66 SNS MEU ii a 3 66 Sys event SUSPOMNG ion tii 3 67 SYS EVEN Tse isss cee sk 3 68 3 5 Flash ROM Access Library Reference 0 00 ee 3 69 E I ge ee 3 69 flash letting ee EE 3 69 Hashar EE o es to AO dE 3 69 E E E T 3 69 3 6 Debug Library Reterenee eeen 3 70 dbp put blokkinni 3 70 dbg put doubleword e 00 e0ee erna 3 70 dbg put doubleword ex 3 70 dbe Pts id 3 71 dbg put Patti Ra 3 71 dbe PUt SIno tan a RS ee 3 71 dbg put Word iii A E iaa 3 72 dbg put word hex 0 00 ea enter 3 72 4 External Function Calls for SDK
25. WORD and the IntervalTimeouts value is 0 which enables sio read to return immediately Return Value SIO_OK OK SIO_BADPORT Port was not open in advance sio_SetWriteTimeouts Set timeout values for Data Output sio_write and sio_putch Syntax include lt sdksio h gt int sio_SetWriteTimeouts int port DWORD TotalTimeouts Arguments port Async serial port number TotalTimeouts Total timeout values Description Set timeout values for sio_write and sio_putch The Return Value default value is 0 which enables sio_write to always block until 1t is finished writing data The value OXFFFFFFFF enables sio write and sio putch to return immediately without blocking at all The value 0 enables sio write to always block until finished writing data SIO OK OK SIO BADPORT Port was not already open SIO_BADPARM Bad parameter 3 15 sio_term_irq Syntax Arguments Description Return Value sio Tx empty irq Syntax Arguments Description Return Value 3 16 Set an event service routine for the Event Control case when the terminator character is received include lt sdksio h gt int sio term irq int port void func int port char code port Async serial port number func event service routine entry If the func is NULL it will disable this routine code terminator code Set an event service routine for the case when the terminator character is received When the terminator character is recei
26. a is not lost or duplicated SOCK_DGRAM sockets allow sending and receiving of datagrams to and from arbitrary peers using sendto and recvfrom If such a socket is connect ed to a specific peer datagrams may be sent to that peer using send and may be received from only this peer using recv If no error occurs socket returns a descriptor referencing the new socket Otherwise it returns 1 and the global variable errno contains one of the following values EMFILE No more file descriptors are available EPROTONOSUPPO The specified address family or RT protocol is not supported accept bind connect getsockname getsockopt setsockopt listen recv recvfrom select send sendto shutdown 1octlsocket 3 3 Simplified Socket Library Reference net_get_gateway Syntax Arguments Description Return Value net_get_IP Syntax Arguments Description Return Value Get local default gateway include lt sdknet h gt u_long net get gateway void N A Get local default gateway default gateway IP address Get local IP address include lt sdknet h gt u long net get IP void N A Get local IP address local IP address net_get MAC_address Get MAC address Syntax Arguments Description Return Value net_get_netmask Syntax Arguments Description Return Value include lt sdknet h gt void net get MAC address u_char mac mac Get MAC address data buff
27. all to listen or accept will refill the queue to the current or most recent backlog if possible and then resume listening for incoming connections backlog is currently limited silently to 5 As in 4 3BSD illegal values less than 1 or greater than 5 are replaced by the nearest legal value If no error occurs listen returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EBADF The descriptor is not a socket EOPNOTSUPP The referenced socket is not of a type that supports the listen operation accept connect socket 3 33 ntohl Syntax Arguments Description Return Value See Also ntohs Syntax Arguments Description Return Value See Also 3 34 Convert an unsigned long from network to host byte order include lt sdksock h gt u long ntohl u long netlong netlong A 32 bit number in network byte order This routine takes a 32 bit number in network byte order and returns a 32 bit number in host byte order ntohl returns the value in host byte order htonl htons ntohs Convert an unsigned short from network to host byte order include lt sdksock h gt u short ntohs u short netshort netshort A 16 bit number in network byte order This routine takes a 16 bit number in network byte order and returns a 16 bit number in host byte order ntohs returns the value in host byte order htonl htons ntohl
28. ch dog reset timeout value is 3 35s Description Enable watchdog Return Value 0 OK 1 error argument sys_exit Exit application Syntax include lt sdksys h gt Void sys_exit void Arguments N A Description To exit user application and return to kernel It will let the user application stop it Return Value N A See Also N A 3 62 sys_get_info Syntax Arguments Description Get server general information include lt sdksys h gt int sys get info struct sdk sysinfo info info A pointer to a buffer that will receive the server general information struct sdk version unsigned short unsigned char unsigned char ext_version sub version main version e g Ver 1 20 3 the main version is 1 sub version is 20 and ext version is 3 struct sdk sysinfo struct sdk version firmware version unsigned long unsigned short unsigned char struct sdk version unsigned short unsigned char unsigned char unsigned char unsigned char e serial_no product_id MAC addr 6 ap Version ap date year ap date month ap date day ap time hour ap time minute Server s firmware version Server s serial number Server s product ID Server Ethernet MAC address User s AP version Date of AP A D e g 2002 Range 1 12 Range 1 31 SP Range 0 23 Range 0 59 Wi 3 63 Return Value sys_get_SerialType Syntax Ar
29. cify a protocol socket allocates a socket descriptor of the specified address family data type and protocol as well as related resources If a protocol is not specified i e equal to 0 the default for the specified connection mode is used Only a single protocol exists to support a particular socket type using a given address format The protocol number to use is particular to the communication domain in which communication is to take place The following type specifications are supported Type Explanation SOCK_STREAM Provides sequenced reliable two way connection based byte streams with an out of band data transmission mechanism Uses TCP for the Internet address family SOCK_DGRAM Supports datagrams which are connectionless unreliable buffers of a fixed typically small maximum length Uses UDP for the Internet address family 3 49 Return Value Error Codes See Also 3 50 Sockets of type SOCK_STREAM are full duplex byte streams A stream socket must be in a connected state before any data may be sent or received on it A connection to another socket is created with a connect call Once connected data may be transferred using send and recv calls When a session has been completed a closesocket must be performed Out of band data may also be transmitted as described in send and received as described in recv The communications protocols used to implement a SOCK_STREAM to ensure that dat
30. cluded only for the sake of compatibility readfds An optional pointer to a set of sockets to be checked for readability writefds An optional pointer to a set of sockets to be checked for writeability exceptfds An optional pointer to a set of sockets to be checked for errors timeout The maximum time for select to wait or NULL for blocking operation This function is used to determine the status of one or more sockets For each socket the caller may request information on read write or error status The set of sockets for which a given status is requested is indicated by an fd set structure Upon return the structure is updated to reflect the subset of these sockets which meet the specified condition and select returns the number of sockets meeting the conditions A set of macros is provided for manipulating an fd set These macros are compatible with those used in the Berkeley software but the underlying representation is completely different Three independent sets of descriptors are watched Those listed in readfds will be watched to see if characters become available for reading those in writefds will be watched to see if it is OK to immediately write on them and those in exceptfds will be watched for exceptions On exit the sets are modified in place to indicate which descriptors actually changed status Any of readfds writefds or exceptfds may be given as NULL if no descriptors are of interest 3 39 Return Valu
31. d the source address upon return fromlen An optional pointer to the size of the from buffer This function is used to read incoming data on a possibly connected socket and capture the address from which the data was sent For sockets of type SOCK_STREAM as much information as is currently available up to the size of the buffer supplied is returned The from and fromlen parameters are ignored for SOCK_ STREAM sockets For datagram sockets data is extracted from the first enqueued datagram up to the size of the buffer supplied If the datagram is larger than the buffer supplied the buffer is filled with the first part of the message and the excess data is lost If from is non zero and the socket is of type SOCK_DGRAM the network address of the peer which sent the data is copied to the corresponding SOCKADDR The value pointed to by fromlen is initialized to the size of this structure and is modified on return to indicate the actual size of the address stored there If no incoming data is available at the socket the recvfrom call wats for data to arrive unless the socket is non blocking In this case a value of 1 is returned with the error code set to EWOULDBLOCK The select calls 3 37 Return Value Error Codes See Also 3 38 may be used to determine when more data arrives If the socket is of type SOCK_STREAM and the remote side has shut down the connection gracefully or the connection has been reset a recv
32. e Error Codes See Also 3 40 Four macros are defined in the header file sdksock h for manipulating the descriptor sets The variable FD_SETSIZE determines the maximum number of descriptors in a set the default value of FD SETSIZE is 32 Internally an fd_set is represented as an array of SOCKET s The macros are FD CLR s sef Removes the descriptor s from set FD ISSET s sef Nonzero if s is a member of the set zero otherwise FD SET s set Adds descriptor s to set FD ZERO sef Initializes the sef to the NULL set The parameter timeout controls how long the select may take to complete If timeout is a null pointer select will block indefinitely until at least one descriptor meets the specified criteria Otherwise timeout points to a struct timeval which specifies the maximum time that select should wait before returning If the timeval is initialized to 0 0 select will return immediately this is used to poll the state of the selected sockets select returns the total number of descriptors which are ready and contained in the fd set structures 0 if the time limit has expired Otherwise 1t returns 1 and the global variable errno contains one of the following values EINVAL The refds wrfds and exfds are all NULL EBADF One of the descriptor sets contains an entry which is not a socket accept connect recv recvfrom send send Syntax Arguments Description Return Value
33. en action was successful and this return value is a descriptor referencing the port The programmer can use this descriptor in the select function from the socket API group to carry out a data read write operation SIO_BADPORT Port number is invalid sio_oqueue Syntax Arguments Description Return Value sio_putch Syntax Arguments Description Return Value Get the length of data not yet sent out In Port Status both the system s output buffer and the driver s output buffer include lt sdksio h gt long sio_oqueue int port port Async serial port number Get the length of data not yet sent out in both the system s output buffer and the driver s output buffer gt 0 length of data in bytes still remaining in the driver s output buffer SIO_BADPORT Port was not open in advance Write a character into the driver s Data Output output buffer include lt sdksio h gt int sio_putch int port int term port Async serial port number term Character 0 255 Write a character into the driver s output buffer SIO_OK OK SIO BADPORT Port was not already open SIO BADPARM Bad parameter SIO ABORT WRITE User abort blocked write SIO_WRITETIMEOUT Write timeout has occurred 3 13 sio_read Syntax Arguments Description Return Value sio_RTS Syntax Arguments Description Return Value 3 14 Read data from the driver s input buffer Data Input include lt sdksio h gt int
34. ep alives if it does the precise semantics are implementation specific but should conform to section 4 2 3 6 of RFC 1122 The following options are supported for setsockopt The Type identifies the type of data addressed by optval Value Type Meaning SO DONTLINGER BOOL _ Don t block close waiting for unsent data to be sent Setting this option is equivalent to setting SO LINGER with 1_onoff set to zero SO_KEEPALIVE BOOL Send keepalives SO_LINGER LINGER Linger on close if il unsent data is present If no error occurs setsockopt returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EFAULT optval is not in a valid part of the process address space EINVAL level is not valid or the information in optval is not valid ENOPROTOOPT The option is unknown or unsupported EBADF The descriptor is not a socket bind getsockopt ioctlsocket socket 3 47 shutdown Syntax Arguments Description Comments Return Value Error Codes See Also 3 48 Disable sends and or receives on a socket include lt sdksock h gt int shutdown int s int how s A descriptor identifying a socket how A flag that describes what types of operation will no longer be allowed shutdown is used on all types of sockets to disable reception transmission or both If how is 0 subsequent receives on the socket will be disallowed This has no effect on the lower protoco
35. er pointer Get MAC address System copies the host MAC address to the mac input buffer Get local subnet mask include lt sdknet h gt u long net get netmask void N A Get local subnet mask local netmask 3 51 tep close Syntax Arguments Description Return Value See Also tcp connect Syntax Arguments Description Return Value 3 52 Close a local TCP port include lt sdknet h gt int tep close int handle handle the value returned from tcp_open Close a local TCP port 0 OK 1 error handle number Connect to specific host IP and port include lt sdknet h gt int tep connect int handle u long rip int rport long tout handle the value return from tcp_open rip remote host IP address that user wants to link rport remote host TCP port no tout wait for TCP connection time out value ms 0 will wait for OK or fail Connect to specific host IP and port 1 connect OK 0 connect fail 1 error handle number 2 error argument 3 timeout counter reached 4 error state already connected 5 the rip rport already in use tcp connect nowait Syntax Arguments Description Return Value See Also tcp get remote Syntax Arguments Description Return Value See Also Connect to specific host IP and port no wait include lt sdknet h gt int ten connect nowait int handle u long rip int rport handle the value returned from tcp_open rip re
36. er pointer len length of the debugging data buffer Print out a block of data for debugging This function returns the length of print out messages dbg put ch dbg put word dbg put doubleword dbg put word hex dbg put doubleword hex dbg put IP dbg put string Print out a 4 byte unsigned long value for debugging Syntax include lt sdkdbg h gt int dbg put doubleword unsigned long value Arguments value The printed out unsigned long value Description Print out a 4 byte unsigned long value for debugging Return Value This function returns the length of print out messages See Also dbg put ch dbg put block dbg put word dbg put word hex dbg put doubleword hex dbg put IP dbg put string dbg put doubleword hex Print out a 4 byte unsigned long value with HEX format for debugging Syntax include lt sdkdbg h gt int dbg put doubleword hex unsigned long value Arguments value The printed out unsigned long value Description Print out a 4 byte unsigned long value with HEX format for Return Value See Also 3 70 debugging This function returns the length of print out messages dbg put ch dbg put block dbg put word dbg put doubleword dbg put word hex dbg put IPQ dbg put string dbg put ch Syntax Arguments Description Return Value See Also dbg put IP Syntax Arguments Description Return Value See Also dbg put string Syntax Arguments Descriptio
37. erial port number Get the size of data accumulated in the system s input buffer and driver s input buffer User must be aware of the fact that there may be a few characters still in the RS 232 UART chip and not yet known when sio iqueue returns a zero value gt 0 data in input buffer bytes SIO_BADPORT Port was not open in advance Set both the DTR and RTS states Port Control include lt sdksio h gt int sio_Ictr int port int mode port Async serial port number mode C_DTR bit 0 C_RTS bit 1 Set both the DTR and RTS states SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter sio_linput Syntax Arguments Description Return Value sio_Istatus Syntax Arguments Description Return Value Read a block of data from the Data Input driver s input buffer include lt sdksio h gt int sio Input int port char buf int len int term port Async serial port number buf receive buffer pointer len buffer length term terminator code Read a block of data from the driver s input buffer until the terminator character is encountered or len bytes of data are read gt 0 length of data received 0 no data received SIO_BADPORT Port was not open in advance SIO BADPARM Bad parameter Get the status of the line Port Status include lt sdksio h gt int sio status int port port Async serial port number Get the status of the line gt 0 line status Bit0 S CTS
38. etermined by the socket options and the flags parameter The latter is constructed by or ing any of the following values 3 35 Return Value Error Codes See Also 3 36 Value Meaning MSG OOB Read out of band data SOCK STREAM only If no error occurs recv returns the number of bytes received If the connection has been closed it returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EBADF EFAULT EOPNOTSUPP ESHUTDOWN EWOULDBLOCK EIO ELENZERO The descriptor is not a socket The buf argument pointer is invalid MSG OOB was specified but the socket is not of type SOCK STREAM The socket has been shutdown it is not possible to recv on a socket after shutdown has been invoked with how set to 0 or 2 The socket is marked as non blocking and the receive operation would block MSG OOB was specified but has not received out of band data The length argument is zero recvfrom read recv send select socket recvfrom Syntax Arguments Description Receive a datagram and store the source address include lt sdksock h gt int recvfrom int s char buf int len int flags SOCKADDR from int fromlen s A descriptor identifying a bound socket buf A buffer for the incoming data len The length of buf flags Specifies the way in which the call is made from An optional pointer to a buffer which will hol
39. from will complete immediately with O bytes received flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket That is the semantics of this function are determined by the socket options and the flags parameter The latter is constructed by or ing any of the following values Value Meaning MSG OOB Read out of band data SOCK STREAM only If no error occurs recvfrom returns the number of bytes received If the connection has been closed it returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EBADF The descriptor is not a socket EFAULT The buf argument pointer is invalid EOPNOTSUPP MSG OOB was specified but the socket is not of type SOCK STREAM ESHUTDOWN The socket has been shut down it is not possible to recvfrom on a socket after shutdown has been invoked with how set to 0 or 2 EWOULDBLOCK The socket is marked as non blocking and the receive operation would block EIO MSG OOB was specified but has not received out of band data ELENZERO The length argument is zero recv send socket select Syntax Arguments Description Determine the status of one or more sockets waiting if necessary include lt sdksock h gt int select int nfds fd set readfds fd set writefds fd set exceptfds struct timeval timeout nfds This argument is ignored and in
40. guments Description Return Value sys get WatchdogStatus Syntax Arguments Description Return Value sys restart system Syntax Arguments Description Return Value 3 64 sys get info returns the buffer data length of the information structure Return of 0 indicates the argument is invalid Get async port interface signal type include lt sdksys h gt sys get SerialType int port port Async serial port number Get async port interface signal type 0 RS 232 1 RS 422 2 RS 485 2w 3 RS 485 4w 1 Bad port Get watchdog status include lt sdksys h gt int sys_get_WatchdogStatus void N A Get watchdog status 0 watch dog timer is disabled 1 watch dog reset timeout value is 335ms refer to sys watchdog enable 8 watch dog reset timeout value is 3 35s Restart system include lt sdksys h gt Void sys_restart_system void N A Restart system N A sys_restart_UserAP Syntax Arguments Description Return Value sys Set RegisterlD Syntax Arguments Description Return Value See Also sys set SerialType Syntax Arguments Description Return Value Restart user AP include lt sdksys h gt void sys restart UserAP void N A Restart user AP N A Set Application ID include lt sdksys h gt void sys Set RegisterlD u long id id Application ID It let user the application ID User can get by DSCI And 0x80000000 to OxFFFFFFFF is reversed for MOX
41. h in bytes this 1s always 4 h addr list A NULL terminated list of addresses for the host Addresses are returned in network byte order The pointer returned points to a structure that is allocated by NPort Server The application must not modify this structure or free any of its components If no error occurs gethostbyname returns a pointer to the hostent structure described above Otherwise it returns a NULL pointer gethostname gethostname Syntax Arguments Description Return Value Error Codes See Also getpeername Syntax Arguments Description Return the standard host name for the local machine include lt sdksock h gt int gethostname char name int namelen name A pointer to a buffer that will receive the host name namelen The length of the buffer This routine returns the name of the local host into the buffer specified by the name parameter The host name is returned as a null terminated string The form of the host name is dependent on the sockets implementation it is a simple host name However it is guaranteed that the name returned will be successfully parsed by gethostbyname If no error occurs gethostname returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values WSAEFAUL The namelen parameter is too small or the name argument pointer is invalid gethostbyname Get the address of the peer to which a socket is connected
42. has been made without first doing a bind this call provides the only means by which you can determine the local association which has been set by the system On return the namelen argument contains the actual size of the name returned in bytes If a socket was bound to INADDR_ANY indicating that any of the host s IP addresses should be used for the socket getsockname will not necessarily return information about the host IP address unless the socket has been connected with connect or accept Return Value Error Codes See Also getsockopt Syntax Arguments Description If no error occurs getsockname returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EFAULT The address of name or namelen argument s not large enough EBADF The descriptor is not a socket bind socket getpeername Retrieve a socket option include lt sdksock h gt int getsockopt int s int level int optname char optval int optlen s A descriptor identifying a socket level The level at which the option is defined the only supported levels are SOL_ SOCKET optname The socket option for which the value is to be retrieved optval A pointer to the buffer in which the value for the requested option is to be returned optlen A pointer to the size of the optval buffer getsockopt retrieves the current value for a socket option associated with a socket of any type
43. i ted 3 7 A aaa 5 bet weet 3 8 sio GetReadTimeouts 00 000e0ra rr err 3 8 sio GetwWrteTmmeouts renn 3 8 e e sg tai ann ls ne le o tate 3 8 e E UE id ess 3 10 SOU iii att 3 10 SO OU iii EES 3 11 SOLAS e ie E E NEEN 3 11 e ent ene WEE 3 12 SIOLOMEG iio 3 12 S10 COP a ae ene 3 12 S10 OGUCUES aida 3 13 SIO PULCHS 3 teeth desk on e A 3 13 e EE 3 14 S103 Rial ica 3 14 510 SetRead Timeouts cocina Ee een aes 3 15 sio SetWwWrteTmmeouts err 3 15 A ete tees waco aes 3 16 S10 TX TE EE 3 16 A AA aa nna 3 17 A le 3 17 3 2 BSD Socket Library Retoerenee ee ecesesceeseeteeeeeeecneeeeenereees 3 18 ACC addon 3 18 Dit ESA eh a id Sete teste 3 19 Clos ESO iia tad 3 21 EL EE 3 22 e e E 3 24 G thogtname cocida 3 25 DE E 3 25 petsocknaMme ii sitiar 3 26 Belge e eee iii 3 27 MO ii ak si skak a nesta 3 29 EOS enskan E ik sana ns si ka a Skal 3 29 TA AR AR A ek RA ag AE 3 30 MEE aid 3 31 lee 3 32 A kst sr Geste 3 33 Ce DEE 3 34 MOS ado te la e dd ad e 3 34 EE 3 35 POCVATOM eent ber Maceta da deta do oT De al te 3 37 selecta cod bit ei Rs ah ees EE ested nh Boat 28 3 39 SONG estes Ahh beer tbe A 3 41 Setsockont coincida 3 45 SAO a aa 3 48 SO II a ee ent ene 3 49 3 3 Simplified Socket Library Reference 3 51 net E EE 3 51 net NR ties 3 51 net get MAC address 3 51 net Gel netmask cui NEEE eE E 3 51 top close e eg 3 52 D TE 3 52 tep connect Dowait nono renna 3 53 tep pet mote sas ag 3 53 TOP AGUC
44. ial port number func event service routine entry If func is NULL this routine will be disabled count data count Set an event service routine for the case when a certain amount of data has been received When there are count bytes of data received in the input buffer the system will call the event service routine SIO_OK OK SIO_BADPORT Port was not open in advance sio_data_status Syntax Arguments Description Return Value sio DIR Syntax Arguments Description Return Value Check if an error occurred when receiving data include lt sdksio h gt int sio_data_status int port port Async serial port number Check if an error occurred when receiving data 0 no error occurred gt 0 but 0 on parity error bit 1 on framing error bit 2 on overrun error bit 3 on overflow error SIO_BADPORT Port was not open in advance Port Status Port Set the DTR state of a port Control include lt sdksio h gt int sio DTR int port int mode port Async serial port number mode 0 Turn DTR off 1 Turn DTR on Set the DTR state of a port SIO_OK OK SIO_BADPORT Port was not open in advance SIO BADPARM Bad parameter 3 5 sio_flowctrl Syntax Arguments Description Return Value sio_ flush Syntax Arguments Description Return Value 3 6 Set hardware and or software Port Control flow control include lt sdksio h gt int sio_flowctrl int port int mode port Async serial port number mode
45. in any state and stores the result in optval Options may exist at multiple protocol levels but they are always present at the uppermost socket level Options affect socket operations such as whether an operation blocks or not the routing of packets out of band data transfer etc The value associated with the selected option is returned in the buffer optval The integer pointed to by optlen should originally contain the size of this buffer on return 1t will be set to the size of the value returned For SO_LINGER this will be the size of a struct linger for all other options it will be the size of an integer If the option was never set with setsockopt then getsockopt returns the default value for the option 3 27 Return Value Error Codes See Also 3 28 The following options are supported for getsockopt The Type identifies the type of data addressed by optval Supported socket options are Value Type Meaning Tf true the SO_LINGER option is disabled Keepalives are being sent Returns the SO_LINGER LINGER current linger options Calling getsockopt with an unsupported option will result in an error code of ENOPROTOOPT If no error occurs getsockopt returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values SO_DONTLINGER BOOL SO_KEEPALIVE BOOL EFAULT The optlen argument was invalid ENOPROTOOPT The option is unknown or unsupported EB
46. include lt sdksock h gt int getpeername int s SOCKADDR name int namelen s A descriptor identifying a connected socket name The structure which is to receive the name of the peer namelen A pointer to the size of the name structure getpeername retrieves the name of the peer connected to the socket s and stores it in the SOCKADDR identified by name It is used on a connected datagram or stream socket On return the namelen argument contains the actual size of the name returned in bytes 3 25 Return Value Error Codes See Also getsockname Syntax Arguments Description 3 26 If no error occurs getpeername returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EFAULT The name argument pointer is invalid or namelen argument is not large enough ENOTCONN The socket is not connected EBADF The descriptor is not a socket bind socket getsockname Get the local name for a socket include lt sdksock h gt int getsockname int s SOCKADDR name int namelen s A descriptor identifying a bound socket name Receives the address name of the socket namelen The size of the name buffer getsockname retrieves the current name for the specified socket descriptor in name It is used on a bound and or connected socket specified by the s parameter The local association is returned This call is especially useful when a connect call
47. ing these functions see the example source code for details of how to include a header file Socket Control This category includes functions to open TCP sockets and set and retrieve communication parameters accept An incoming connection is acknowledged and associated with an immediately created socket The original socket is returned to the listening state bind Assien a focal name to an unnamed socket Remove a socket from the per process object reference table Only blocks if SO_LINGER is set socket Create an endpoint for communication and return a socket getsockopt Retrieve options associated with the specified socket 2 4 Data Input Output This category includes functions to read write data from the socket Function Name Description recv Receive data from a connected socket recvfrom Receive data from either a connected or unconnected socket select Perform synchronous I O multiplexing Send data to a connected socket sendto Send data to either a connected or unconnected socket Socket Status Inquiry This category includes functions to query the communication status from the socket Function Name Description getpeername Retrieve the name of the peer connected to the specified socket Retrieve the current name for the specified socket gethostname Retrieve the name of the local host gethostbyname Retrieve the name s and address corresponding to a host name 2 5 Miscellaneous Thi
48. io_break_ex int port int ms port Async serial port number ms break time in milliseconds Sends out a break signal This function will block transmission until the time has expired and is the same as sio_break except that the time unit is measured in milliseconds SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter Set an event service routine for the Event Control case when a BREAK signal is received include lt sdksio h gt int sio break irq int port void func int port port Async serial port number func event service routine entry If func is NULL this routine will be disabled Set an event service routine for the case when a BREAK signal is received When a BREAK signal is encountered the system will call the event service routine SIO_OK OK SIO_BADPORT Port was not open in advance 3 3 sio_close Syntax Arguments Description Return Value sio ent irq Syntax Arguments Description Return Value 3 4 Disable a serial port Port Control include lt sdksio h gt int sio_close int port port Async serial port number Disable a serial port so that it cannot receive transmit data SIO_OK OK SIO_BADPORT Port was not open in advance Set an event service routine for the Event Control case when a certain amount of data has been received include lt sdksio h gt int sio_cnt_irq int port void func int port int count port Async ser
49. ion status from the serial port sio_Istatus Get line status Size of data accumulated in driver s input buffer sio_oqueue Size of data not yet sent out still kept in driver s output buffer Get the settings for parity data bits etc sio_data_status Check if errors occur when receiving data Event Control This category includes functions to set the communication event service routines for the serial port sio_term_irq Set event service routine when termination en AA sio_ent_irq Set event service routine when a certain amount of TT AAA sio_modem_irq Set event service routine when line status is changed sio_break_irq Set event service routine when break signal is received sio_Tx_empty_irq Set event service routine when transmit buffer is empty 2 3 Miscellaneous This category includes special COM port functions Function Name sio_break Send out BREAK signal sio break ex Send out BREAK signal sio ActXon Causes transmission to act as if an XON character has been received sio_ActXoff Causes transmission to act as if an XOFF character has been received BSD Socket API In this section we categorize the BSD Socket library routines according to their function Socket Control Data Input Output Socket Status Inquiry and Miscellaneous See Section 3 2 for a more detailed description of these functions You should also note that the header file sdksock h must be included in your source code when call
50. l layers For TCP the TCP window is not changed and incoming data will be accepted but not acknowledged until the window is exhausted For UDP incoming datagrams are accepted and queued If how is 1 subsequent sends are disallowed For TCP sockets a FIN will be sent Setting how to 2 disables both sends and receives as described above Note that shutdown does not close the socket and resources attached to the socket will not be freed until closesocket is invoked shutdown does not block regardless of the SO_LINGER setting on the socket An application should not rely on being able to re use a socket after it has been shut down In particular a Sockets implementation is not required to support the use of connect on such a socket If no error occurs shutdown returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EINVAL how is not valid ENOTCONN The socket is not connected SOCK_STREAM only EBADF The descriptor is not a socket connect socket socket Syntax Arguments Description Create a socket include lt sdksock h gt int socket int af int type int protocol af An address format specification The only format currently supported is AF INET which is the ARPA Internet address format type A type specification for the new socket protocol A particular protocol to be used with the socket or 0 if the caller does not wish to spe
51. led This is consistent with BSD sockets This function is a subset of ioctl as used in Berkeley sockets Upon successful completion the ioctlsocket returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EINVAL cmd is not a valid command or argp is not an acceptable parameter for cmd or the command is not applicable to the type of socket supplied EBADF The descriptor s is not a socket socket setsockopt getsockopt listen Syntax Arguments Description Compatibility Return Value Error Codes See Also Establish a socket to listen for incoming connection include lt sdksock h gt int listen int s int backlog s A descriptor identifying a bound unconnected socket backlog The maximum length to which the queue of pending connections may grow To accept connections a socket is first created with socket a backlog for incoming connections is specified with listen and then the connections are accepted with accept listen applies only to sockets that support connections i e those of type SOCK_STREAM The socket s is put into passive mode where incoming connections are acknowledged and queued pending acceptance by the process listen attempts to continue to function rationally when there are no available descriptors It will accept connections until the queue is emptied If descriptors become available a later c
52. ming connection 1 connect OK or already connected 0 connect fail 1 error handle number 2 this handle was opened by tcp_open 3 timeout counter reached 4 error state already connected tep listen nowait Syntax Arguments Description Return Value tep listento Syntax Arguments Description Return Value Places a socket in a state where it is listening for an incoming connection no wait include lt sdknet h gt int tep listen nowait int handle handle the value returned from tcp_open Places a socket a state where it is listening for an incoming connection no wait 0 start to listen 1 error handle number 2 this handle was opened by tep open 3 error state already connected Listen for a specific incoming connection include lt sdknet h gt int tep listento int handle u long rip int rport long tout handle the value returned from tcp_open rip remote host IP address that user wants to link to 0 indicates don t case remote IP address rport remote host TCP port No 0 indicates don t case the TCP port number tout wait for listen timeout value unit is ms Listen for a specific incoming connection 1 connect OK or already connected 0 connect fail 1 error handle number 2 this handle was opened by tcp_open 3 timeout counter reached 4 error state already connected 3 55 tep listento nowait Listen for a specific incoming connection no wait Syntax
53. mote host IP address that user wants to link to rport remote host s TCP port No Connect to specific host s IP and port no wait O start to connect 1 error handle number 2 error argument 3 error state already connected 4 the rip rport is already in use Get connected host s IP and port include lt sdknet h gt int tcp_get_remote int handle u long rip int rport handle the value returned from tcp_open rip connected host s IP address pointer rport connected host s TCP port number pointer Get connected host s IP and port 0 get OK 1 error handle 2 error argument 3 No connection 3 53 tep iqueue Syntax Arguments Description Return Value tep listen Syntax Arguments Description Return Value 3 54 Get the size of data accumulated in TCP driver s input buffer include lt sdknet h gt int tcp_iqueue int handle handle the value returned from tcp_open Get the size of data accumulated in TCP driver s input buffer gt 0 TCP input buffer queued data size 1 error handle number 2 This is not a TCP handle 3 TCP not connected Places a socket in a state where it is listening for an incoming connection include lt sdknet h gt int tcp_listen int handle long tout handle the value return from tcp_open tout wait for listen time out value unit is ms 0 for wait for someone to connect Places a socket a state where it is listening for an inco
54. n Return Value See Also Print out a character for debugging include lt sdkdbg h gt int dbg put ch char ch ch The character value that will be printed out Print out a character for debugging This function returns the length of the printed out messages dbg put block dbg put word dbg put doubleword dbg put word hex dbg put doubleword hex dbg put IP dbj put string Print out an IP address in the a b c d format for debugging include lt sdkdbg h gt int dbg put IP unsigned long ipaddr ipaddr The printed out Internet hosts IP address Print out an IP address in the a b c d format for debugging This function returns the length of print out messages dbg put ch dbg put block dbg put word dbg put doubleword dbg put word hex dbg put doubleword hex dbg put string Print out a string for debugging include lt sdkdbg h gt int dbg put string char buf buf The printed out debugging data buffer s pointer Print out a string for debugging This function returns the length of print out messages dbg put ch dbg put block dbg put word dbg put doubleword dbg put word hex dbg put doubleword hex dbg put IP 3 71 dbg put word Syntax Arguments Description Return Value See Also dbg put word hex Syntax Arguments Description Return Value See Also 3 72 Print out a 2 byte unsigned integer value for debugging include lt sdkdbg h g
55. n depends on the amount of free space in the driver s output buffer sio_write is always non block by default sio set WriteTimeout can be used to set timeouts for sio_write SIO WRITETIMEOUT will be returned for sio write when write timeouts sio_abort_write can be used to abort any blocked sio_write with return value SIO ABORT WRITE gt 0 length of data transmitted SIO_BADPORT Port was not already open SIO_BADPARM Bad parameter SIO ABORT WRITE User abort blocked write SIO WRITETIMEOUT Write timeout has occurred 3 17 3 2 BSD Socket Library Reference accept Syntax Arguments Description 3 18 Accept a connection on a socket include lt sdksock h gt int accept int s SOCKADDR addr int addrlen s A descriptor identifying a socket which is listening for connections after a listen addr An optional pointer to a buffer that receives the address of the connecting entity as known to the communications layer The exact format of the addr argument is determined by the address family established when the socket was created addrlen An optional pointer to an integer that contains the length of the address addr This routine extracts the first connection on the queue of pending connections on s creates a new socket with the same properties as s and returns a handle to the new socket If no pending connections are present on the queue and the socket is not marked as non blocking accept blocks
56. ndto is normally used on a SOCK_DGRAM socket to send a datagram to a specific peer socket identified by the to parameter On a SOCK STREAM socket the to and tolen parameters are ignored in this case the sendto is equivalent to send To send a broadcast on a SOCK DGRAM only the address in the to parameter should be constructed using the special IP address INADDR BROADCAST defined in sdksock h together with the intended port number It is generally inadvisable for a broadcast datagram to exceed the size at which fragmentation may occur which implies that the data portion of the datagram excluding headers should not exceed 512 bytes If no buffer space is available within the transport system to hold the data to be transmitted sendto will block unless the socket has been placed in a non blocking I O mode On non blocking SOCK_STREAM sockets the number of bytes written may be between 1 and the requested length depending on buffer availability on both the local and foreign hosts The select call may be used to determine when it is possible to send more data 3 43 Return Value Error Codes See Also 3 44 flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket That is the semantics of this function is determined by the socket options and the flags parameter The latter is constructed by or ing any of the following values Value Meaning
57. nes according to their function Port Control Data Input Data Output Port Status Inquiry Event Control and Miscellaneous See Section 3 1 for a more detailed description of these functions You should also note you must include the header file sdksio h in your source code that when calling these functions see the example source code for details of how to include a header file Port Control This category includes functions to open serial ports set communication parameters and control signal lines Data Input This category includes functions to read data from the COM port sio_getch Read one character at a time from driver s input buffer Read a block of data from the driver s input buffer sio_SetReadTimeouts Set timeouts for sio_read sio GetReadTimeouts Get timeouts for sio_read sio_AbortRead Abort when reading a block of data for sio_read sio_linput Read a block of data ending with a termination character Data Output This category includes functions to write data to the serial port Function Name sio_putch Write one character at a time to driver s output buffer sio_write Write a block of data probably only a partial block will be written sio_SetWriteTimeouts Set timeouts for sio write sio GetWriteTimeouts Get timeouts for sio write sio_AbortWrite Abort when writing a block of data for sio write Port Status Inquiry This category includes functions to query the communicat
58. or close close SO_DONTLINGER Don t Graceful No care SO_LINGER Zero Hard No SO_LINGER Non Graceful Yes Zero If SO_LINGER is set Ge the onoff field of the linger structure is non zero with a zero timeout interval 1_linger is zero closesocket is not blocked even if queued data has not yet been sent or acknowledged This is called a hard or abortive close because the socket s virtual circuit is reset immediately and any unsent data is lost If SO_LINGER is set with a non zero timeout interval the closesocket call blocks until the remaining data has been sent or until the timeout expires This is called a graceful disconnect 3 21 Return Value Error Codes See Also connect Syntax Arguments Description 3 22 IfSO DONTLINGER is set on a stream socket i e the l onoff field of the linger structure is zero the closesocket call will return immediately However any data queued for transmission will be sent if possible before the underlying socket is closed This is also called a graceful disconnect Note that in this case the Windows Sockets implementation may not release the socket and other resources for an arbitrary period which may affect applications which expect to use all available sockets If no error occurs closesocket returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EBADF The descriptor is not a socket accept socket ioctlsocket
59. pplication programming in the presence of multi homed hosts If the port is specified as 0 the Windows Sockets implementation will assign a unique port to the application with a value between 1024 and 30000 The application may use getsockname after bind to learn the address that has been assigned to it but note that getsockname will not necessarily fill in the Internet address until the socket is connected since several Internet addresses may be valid if the host is multi homed If no error occurs bind returns 0 Otherwise it returns 1 and the global variable errno contains one of the following values EFAULT The namelen argument is too small less than the size of a SOCKADDR or the name argument pointer is invalid EINVAL The socket is already bound to an address EBADF The descriptor is not a socket connect listen getsockname setsockopt socket closesocket Syntax Arguments Description Close a socket include lt sdksock h gt int closesocket int s s A descriptor identifying a socket This function closes a socket More precisely it releases the socket descriptor s so that further references to s will fail with the error EBADF If this is the last reference to the underlying socket the associated naming information and queued data are discarded The semantics of closesocket are affected by the socket options SO_LINGER and SO_DONTLINGER as follows Option Interval Type of Wait f
60. ptlen The size of the optval buffer setsockopt sets the current value for a socket option associated with a socket of any type in any state Although options may exist at multiple protocol levels this specification only defines options that exist at the uppermost socket level Options affect socket operations such as whether expedited data is received in the normal data stream whether broadcast messages may be sent on the socket etc There are two types of socket options Boolean options that enable or disable a feature or behavior and options which require an integer value or structure To enable a Boolean option optval points to a nonzero integer To disable the option optval points to an integer equal to zero optlen should be equal to sizeof int for Boolean options For other options optval points to the an integer or structure that contains the desired value for the option and optlen is the length of the integer or structure 3 45 3 46 SO_LINGER controls the action taken when unsent data is queued on a socket and a closesocket is performed See closesocket for a description of the way in which the SO_LINGER settings affect the semantics of closesocket The application sets the desired behavior by creating a struct linger pointed to by the optval argument with the following elements struct linger int 1l onoff int 1 linger To enable SO_LINGER the application should set 1 onoff to a non zero val
61. rt number buf send data buffer pointer len send data length Sends data to a specific destination gt 0 sent out data length 1 send failed 3 4 System Control Library Reference sys_clock_ms Syntax Arguments Description Return Value See Also sys_clock_s Syntax Arguments Description Return Value See Also sys_disable_watchdog Syntax Arguments Description Return Value Read the server s time milliseconds count from power up include lt sdksys h gt unsigned long sys clock ms void N A Read the server s time milliseconds count from power up This function returns server s time counter in milliseconds sys_clock_s Read the server s time seconds count from power up include lt sdksys h gt unsigned long sys clock s void N A Read the server s time seconds count from power up This function returns server s time counter in seconds sys clock ms Disable watchdog include lt sdksys h gt void sys watchdog disable void N A Disable watchdog N A 3 61 sys_enable_watchdog Enable watchdog Syntax int sys enable watchdog int mode Arguments mode 1 watch dog reset timeout value is 335ms 2 watch dog reset timeout value is 419ms 3 watch dog reset timeout value is 671ms 4 watch dog reset timeout value is 838ms 5 watch dog reset timeout value is 1 34s 6 watch dog reset timeout value is 1 68s 7 watch dog reset timeout value is 2 68s 8 wat
62. s Changes are periodically made to the information herein to correct such errors and these changes are incorporated into new editions of the publication MOXA Internet Services Customer satisfaction is our number one concern To ensure that customers receive the full benefit of our products Moxa Internet Services has been set up to provide technical support driver updates product information and user s manual updates The following services are provided E mail for technical support address support moxa com tw World Wide Web WWW site for product information address http www moxa com or http www moxa com tw Table of Contents NNER a NEE 1 1 Moxa API Quick Reterence nono nccono nina nccnnos 1 2 2 SDK APLOVervieW os 2 1 EIS O AP ita dades da 2 2 BSD Socket AP 2 4 Simplified Socket API linia in e sd dis 2 7 System Control API iessen ee ea a ess 2 9 Flash ROM Access AT 2 10 Debug APLI 2 10 3 SDK API Reference commmcccnconccccnnanccncnnnccnnnnnn crasas 3 1 3 1 Serial I O Library Reference 3 1 sio AbortRead ici ciao 3 1 SN A EEee 3 1 SIA COTE A iia be 3 2 SION ACE OMA iia 3 2 SO e ME 3 2 A eer Adel ee AE ee ee eee RE 3 3 A EX siss ks a Ol 3 3 E es 3 3 Ste ClOSG sin 4 sea aa TA Sa Ed 3 4 SIO CME UA A AA O ran 3 4 10 data status con iia das Saa 3 5 IO DTR A Si Br Sr 3 5 S10 H tt ia ic 3 6 S102 lt EA 3 6 SiO petbaud ii ti dci 3 7 A at a 0 aa 0 Aa si 3 7 si pel Wi
63. s category includes special socket functions Function Name Description htonl Convert a 32 bit quantity from host byte order to network byte order htons Convert a 16 bit quantity from host byte order to network byte order inet addr Convert a character string representing a number in the Internet standard notation to an Internet address value inet ntoa Convert an Internet address value to an ASCII string in notation Ge a b c d ntohl Convert a 32 bit quantity from network byte order to host byte order ntohs Convert a 16 bit quantity from network byte order to host byte order 2 6 Simplified Socket API In this section we categorize the Simplified Socket library routines according to their function Socket Control Data Input Output and Socket Status Inquiry See Section 3 3 for a more detailed description of these functions You should also note that calling these functions requires that the header file sdknet h must be included in your source code see the example source code for details of how to include a header file Socket Control This category includes functions to open TCP sockets and set and retrieve communication parameters Connect to specific host IP and port R Place a socket in a state where it is listening for an tep listen incoming connection tep listento Listen for a specific incoming connection tep connect nowait Connect to a specific host IP and port no wait P Place a
64. sio read int port char buf int len port Async serial port number buf receive buffer pointer len buffer length Read data from the driver s input buffer If the length of data in the driver s input buffer is less than the user s buffer then all data in the driver s input buffer will be transferred to the user s buffer Otherwise only len bytes will be transferred to the user s buffer sio set ReadTimeout can be used to set timeouts for sio_read sio_AbortRead can be used to abort any blocked sio read gt 0 length of data received 0 no data received SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter Set the RTS state of a port Port Control include lt sdksio h gt int sio RTS int port int mode port Async serial port number mode 0 Turn RTS off 1 Turn RTS on Set the RTS state of a port SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter SIO_RTS BY HW Can t control the port because it is set as auto H W flow control by sio_flowctrl sio_SetReadTimeouts Set timeout values for Data Input Syntax Arguments Description sio_read and sio_getch include lt sdksio h gt int sio_SetReadTimeouts int port DWORD TotalTimeouts DWORD IntervalTimeouts port Async serial port number TotalTimeouts Total timeout values IntervalTimeouts Interval timeout values Set timeout values for sio read and sio getch The default TotalTimeouts value is MAXD
65. ss Library Reference flash_erase Syntax Arguments Description Return Value flash_length Syntax Arguments Description Return Value flash_read Syntax Arguments Description Return Value flash_write Syntax Arguments Description Return Value Erase flash ROM include lt sdkflash h gt int flash erase void N A Erase flash ROM 0 OK 1 fail Get current data length at the flash ROM include lt sdkflash h gt long flash length void N A Get current data length at the flash ROM gt 0 Current data length at the flash ROM 0 after calling sys flash erase Max length is 65536 64 KB Read data from the flash ROM include lt sdkflash h gt Long flash read long offset char buffer long size buffer read buffer pointer size buffer size Read data from the flash ROM gt 0 read data size 1 read failed Write data to the flash ROM include lt sdkflash h gt long flash write char buffer long size buffer write data buffer pointer size write data size gt from 1 to 65536 Write data to the flash ROM gt 0 write length 1 write failed 2 Need to erase the flash ROM first 3 69 3 6 Debug Library Reference dbg_put_block Syntax Arguments Description Return Value See Also dbg_put_doubleword Print out a block of data for debugging include lt sdkdbg h gt int dbg put block char buf int len buf The print out debugging data buff
66. sys timeout 1 gt sio term irq 2 gt sio ent irq 3 gt sio modem mo 4 gt sio break irq 5 gt sio tx Empty_irq args If type is 0 args is the timeouts interrupt subroutine If type is not 0 args is the serial port number Eq 1 for NPort 4511 s serial port This function suspends the specific interrupt when the subroutine is called not from specific interrupt preventing unpredictable situations from occurring This function is usually called at the beginning of a subroutine For example suppose brk_isr is sio_break_irq interrupt subroutine ISR If it is called from the main program instead of a break interrupt this function will prevent unpredictable results 0 OK 1 Fail sys event resume 3 67 sys event resume Syntax Arguments Description Return Value See Also 3 68 Resume interrupt include lt sdksys h gt void sys event resume int type u long args type interrupt type 0 gt sys timeout 1 gt sio term irq 2 gt sio ent irq 3 gt sio modem irq 4 gt sio break irq 5 gt sio tx Empty irq args If type is 0 args is the timeouts interrupt subroutine If type is not 0 args is the serial port number Eq 1 for NPort 4511 s serial port This will resume the interrupt that is suspended by sys_event_suspend in subroutine This function is usually called at the end of the subroutine 0 OK 1 Fail sys event suspend 3 5 Flash ROM Acce
67. t int dbg put word unsigned short value value The printed out unsigned short value Print out a 2 byte unsigned integer value for debugging This function returns the length of print out messages dbg put ch dbg put block dbg put doubleword dbg put word hex dbg put doubleword hex dbg put IP dbg put string Print out a 2 byte unsigned integer value with HEX format for debugging include lt sdkdbg h gt int dbg put word hex unsigned short value The print out unsigned short value Print out a 2 byte unsigned integer value with HEX format for debugging This function returns the length of print out messages dbg put ch dbg put block dbg put word dbg put doubleword dbg put doubleword hex dbg put IP Q dbg put string value 4 External Function Calls for SDK We have tested the following standard Turbo C string functions with SDK and have verified that they can be used without any problem Note that to use these string functions you must link to the es lib library file with a tlink command similar to the one shown here Spath gt tlink t s cOsdk ap ap ap moxa_sdkte tc lib cs 1lib NOTE It is important to keep in mind that you must use the complete path to link to the to the cs lib library file If you would like to use other Turbo C standard functions we cannot guarantee that they will work with SDK When using Borland C use the same method as for Turbo C
68. t int sio_GetWriteTimeouts int port DWORD TotalTimeouts Arguments port Async serial port number TotalTimeouts Total timeout values Description Get timeout values for sio_write and sio_putch Return Value SIO OK OK SIO_BADPORT Port was not already open sio_ioctl Control the settings of the serial Port Control 3 8 port s I O control register Syntax Arguments Description Return Value include lt sdksio h gt int sio_ioctl int port int baud int mode port Async serial port number baud bits sec 0 50 6 600 12 9600 1 75 7 1200 13 19200 2 110 8 1800 14 38400 3 134 5 9 2400 15 57600 4 150 10 4800 16 115200 5 300 11 7200 17 230400 mode bit ent OR stop bit OR parity bit emt bits 0 1 0x00 bit_5 0x01 bit_6 0x02 bit_7 0x03 bit_8 stop bit bit2 0x00 stop 1 0x04 stop 2 parity bits 3 4 5 0x00 none 0x08 odd 0x18 even 0x28 mark 0x38 space Control the settings of the serial port s I O control register such as baud rate parity data bits and stop bit SIO_OK OK SIO_BADPORT Port was not open in advance SIO_BADPARM Bad parameter 3 9 sio iqueue Syntax Arguments Description Return Value sio lctrl Syntax Arguments Description Return Value 3 10 Get the size of data accumulated in Port Status the system s input buffer and driver s input buffer include lt sdksio h gt long sio_iqueue int port port Async s
69. the caller until a connection is present If the socket is marked non blocking and no pending connections are present on the queue accept returns an error as described below The accepted socket may not be used to accept more connections The original socket remains open The argument addr is a result parameter that is filled in with the address of the connecting entity as known to the communications layer The exact format of the addr parameter is determined by the address family in which the communication is occurring The addrlen is a value result parameter it should initially contain the amount of space pointed to by addr on return it will contain the actual length in bytes of the address returned This call is used with connection based socket types such as SOCK_ STREAM If addr and or addrlen are equal to NULL then no information about the remote address of the accepted socket is returned Return Value Error Codes See Also Warnings bind Syntax Arguments Description If no error occurs accept returns a value of type int which is a descriptor for the accepted packet Otherwise a value of 1 is returned and the global variable errno contains one of the following values The integer referred to by addrlen initially contains the amount of space pointed to by addr On return it will contain the actual length in bytes of the address returned EBADF The first argument does not specify a valid descriptor EOPNOTSU
70. timeout event service routine sys get info Get server s general information Enable watchdog Disable watchdog Get watchdog status Restart system Restart user AP Get current async port interface signal type Set the async port interface signal type Suspend interrupt sys event resume Resume interrupt Flash ROM Access API This section presents the Flash Library routines and gives a brief description of each routine For a more detailed description of these routines see Section 3 5 You should also note that the header file sdkflash h must be included in your source code when calling these functions see the example source code for details of how to include a header file Debug API This section presents the Debug Library routines and gives a brief description of each routine For a more detailed description of these routines see Section 3 6 You should also note that the header file sdkdbg h must be included in your source code when calling these functions see the example source code for details of how to include a header file dbg put ch Print out a character for debugging dbg_put_block Print out a block of data for debugging dbg put word Print out a 2 byte unsigned integer value for debugging dbg put doubleword Print out a 4 byte unsigned long value for debugging dbg put word hex Print out a 2 byte unsigned integer value with HEX format for debugging dbg put doubleword hex Print out a 4 byte
71. tion as a b c d Note that the string returned by inet ntoa resides in memory which is allocated by the sockets implementation The application should not make any assumptions about the way in which the memory is allocated The data is guaranteed to be valid until the next sockets API call within the same thread but no longer If no error occurs inet ntoa returns a char pointer to a static buffer containing the text address in standard notation Otherwise it returns NULL The data should be copied before another Windows Sockets call is made inet_addr 3 31 ioctlsocket Syntax Arguments Description Compatibility Return Value Error Codes See Also 3 32 Control the mode of a socket include lt sdksock h gt int ioctlsocket int s long cmd u long argp s A descriptor identifying a socket cmd The command to perform on the socket s argp A pointer to a parameter for cmd This routine may be used on any socket in any state It is used to get or retrieve operating parameters associated with the socket independent of the protocol and communications subsystem The following commands are supported Command Semantics FIONBIO Enable or disable non blocking mode on the socket s argp points to an unsigned long which is non zero if non blocking mode is to be enabled and zero if it is to be disabled When a socket is created it operates in blocking mode i e non blocking mode is disab
72. ue set 1 linger to 0 or the desired timeout in seconds and call setsockopt The timeout value should be in the interval between 0 to10 in seconds To enable SO DONTLINGER i e disable SO_LINGER onoff should be set to zero and setsockopt should be called By default a socket may not be bound see bind to a local address which is already in use On occasion however it may be desirable to re use an address in this way Since every connection is uniquely identified by the combination of local and remote addresses there is no problem with having two sockets bound to the same local address as long as the remote addresses are different To inform the Windows Sockets implementation that a bind on a socket should not be disallowed because the desired address is already in use by another socket the application should set the SO REUSEADDR socket option for the socket before issuing the bind Note that the option is interpreted only at the time of the bind it is therefore unnecessary but harmless to set the option on a socket which is not to be bound to an existing address and setting or resetting the option after the bind has no effect on this or any other socket Return Value Error Codes See Also An application may request that the Sockets implementation enable the use of keep alive packets on TCP connections by turning on the SO KEEPALIVE socket option A Sockets implementation need not support the use of ke
73. ved the system will call the event service routine SIO OK OK SIO_BADPORT Port was not open in advance Set an event service routine Event Control for the case when the last character in the output buffer was sent include lt sdksio h gt int sio_Tx_empty_irq int port void func int port port Async serial port number func event service routine entry If the func is NULL it will disable this routine Set an event service routine for the case when the last character in the output buffer was sent When the Tx empty signal is encountered the system will call the event service routine SIO_OK OK SIO_BADPORT Port was not open in advance sio_Tx_hold Syntax Arguments Description Return Value sio_write Syntax Arguments Description Return Value Check why data could not be Port Status transmitted include lt sdksio h gt int sio_Tx_hold int port port Async serial port number Check the reason why data could not be transmitted gt 0 bit 0 on could not transmit data because CTS is low bit 1 on could not transmit data because XOFF char received SIO_BADPORT Port was not open in advance Write a block of data to the Data Output driver s output buffer include lt sdksio h gt int sio write int port char buf int len port Async serial port number buf transmit string pointer len transmit string length Write a block of data to the driver s output buffer The actual length of data writte

Download Pdf Manuals

image

Related Search

Related Contents

Samsung Flight Manual  Wiley iWork '09 For Dummies  Anthro Trolley  Câmera Digital DC4365BR Câmera Digital DC4365BR  IBM 49Y9898 tape drive  GBC 41611E laminator pouch  

Copyright © All rights reserved.
Failed to retrieve file