Home

ADAM-4500 Series

image

Contents

1. Local System Adam 4500 m Adam 4500 Series System Conf amp Init System Configuration m IP DH atic IP C DHCP Address 10 o Jo J2 ateway Se LINO 3072 3t w MOBILE S D s ADV SRAMD I Control Panel e Shared Docu My Documen D6 07 25 5 04 00 AM 6 07 25 5 04 00 AM 06707725 5 04 00 AM D6 07 25 5 04 00 AM D6 07 25 5 04 00 AM 6 07 25 5 05 00 AM 6 07 25 5 04 00 AM 6 07 25 6 00 00 AM r FTP amp HTTP Configuration FTP ID Password Password Rights Change Dir Rights GetFiles 6 object s Creat Del Dir Post Files Write File Use CGI Read File Update XTransft lt lt Get ACI M System Initialization w System Files HTTPFTP Server FTP Server HTTP Server Go C transi XTransft lt lt Get ACK for EOT gt gt 2 Build DEMOTS EXE from DEMOTS PRJ under ADAM 4500 Series Utility Source Example DemoModbus directory and download DEMOTS EXE onto drive D under root directory lal x File Help Local System ADAM 4500 Series iH re E 2 gi cow i Name Size Type Modified E DemoRC PRJ G CoNF File Folder 2006 07 25 6 01 00 AM E DemoRS c 1KB CFil C WEBROOT File Folder 2006 07 25 6 01 00 AM E DEMORS DSK 3KB DSK fs AUTORUN BAT 1KB MS DOS B 2006 07 25 6 01 00 AM E DEM RS EXE 41KB Appl
2. cceeeeee eere rreeen 3 1 System Hardware Configuration 3 2 Install Utility on Host PC 3 3 ADAM 4500 Series Utility Overview c T T EU 3 4 Initialize Drive D to Default Settings 3 5 Configure IP Address and HTTP FTP User Password sat 3 6 Download and Run Application Program Automatically Aller BOOTUP xusbsescodd duci a a aa 3 7 Backup Drive D as Image File 3 8 Restore Drive D from Image File Chapter 4 Guidelines for Network Functions AA PIP Serve eut oe oco easet a a 4 2 TITTP SerUVer iiic iode eee encore settee nets 4 3 Send Mail 4 4 Modbus TCP Server T SESE S E 4 5 Modbus TCP Client eeeeerr rennen 4 6 Modbus RTU Slave ceeeeeeee nennen nn 4 7 Modbus RTU Master eere 4 8 TCP Server and Client eee enne 4 9 UDP Connection eeerrr nm HM IIIS 41 66 4 10 FIP Cli nt noi heworodesxc ovuelsevizoxesisvenervhrwlcone ATO Chapter 5 Programming and Function Library 5 1 5 1 INTROGUCUION Bee DE 5 2 Category of Function Libraries 5 7 5 3 Function Library Description 5 12 Chapte
3. ADAM 4500 Series sockETP ExE File Folder 2006 06 86 1 00 00 AM File Folder 20060616 1 00 00 AM 1KB MS DOSB 2006 0646 1 00 00 AM 13KB MS DOS A 2006 0646 1 00 00 AM 35KB Application 2006 0646 1 00 00 AM 48KB Application 2006 0646 1 00 00 AM 6 objects 95 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF lt DIR gt 06 16 2006 WEBROOT lt DIR gt 06 16 2006 AUTORUN BAT 128 06 16 2006 AX8796 COM 13 184 06 16 2006 CFGIO EXE 35 328 06 16 2006 SOCKETP EXE 48 896 06 16 2006 6 file s 97 536 bytes M pmb E EHE 02a 02a 02a 02a 02a 02a 751 616 bytes free A start euyg iii Adam4500 mE T 3 11PM ADAM 4500 Series User s Manual 3 23 Chapter 3 Program Download 3 Click the Advantech Image Worker button to perform the backup function fill ADAM 4500 Series Utility Yer 1 13 2 4Bixi File Help Local System Refresh Folder Name Size Type Modified CONF File Folder 200606416 1 00 00 AM C WwEBROOT File Folder 2006 0616 1 00 00 AM Ss AUTORUN BAT 1KB MS DOSB 2006 0646 1 00 00 AM P ax8796 COM 13KB MS DOS A 2006 0616 1 00 00 4M crFaio EXE 35KB Application 200606416 1 00 00 AM sockETP EXE 48KB Application 20060646 1 00 00 AM Se UNO 3072 3074 Local Disk s Removable Disk Removabl s Removable Disk Removabl ss ADV SRAMDRV Removabl J Control
4. Chapter 4 Guidelines for Network Functions o 6 Put switch of the two ADAM 4500 Series Controllers into Normal mode and reboot the two controllers Run TSERVER EXE on the ADAM 4500 Series Controller which is the TCP server i ADAM 4500 Series Utility Ver 1 14 E l xj File Help Local System ADAM 4500 Series ajoj zz pur ea l Name Size Type Moified E TCLIENT EXE 35KB Applical CONF File Folder 2006 07 25 6 01 00 AM TCP_Client c 4KB C File Cj WEBROOT File Folder 2006 07 25 6 01 00 AM B TCP_Server c 8KB CFile amp uroRUN BAT 1KB MS DOS B 2006 07 25 6 01 00 AM Ei TSERVER EXE 35KB Applical 774x8786 coM 13KB MS DOS A 2006 07 25 6 01 00 AM E TServer PRJ BKB PR File I CFGIO EXE 35KB Application 2006 07 25 6 01 00 AM 1 UCLIENT EXE 35KB Applical 7 pEMORS EXE 41KB Application 2006 07 25 7 01 00 AM UDP_Client c 4KB CFile DEMOTS EXE 51KB Application 2006 07 25 6 01 00 4M UDP_Server c 4KB CFile SOCKETP EXE 48KB Application 2006 07 25 6 01 00 AM USERVER EXE 34KB Applical TSERVER EXE 35KB Application 2006 07 25 7 02 00 AM 9 object s 159 4 KB 9 object s 220 8 KB 622 592 bytes free Compiled Apr 13 2004 4 11 1525 Processing D CONF socket cfg if0 Packet driver at Ox60 using h w int 7 Unknown host O Hostname 10 0 0 2 if0 10 0 0 2 Net mask 255 0 0 0 D gt tserver Server started wait for connect Run TCLIENT EXE add IP address of TC
5. Digital I O modules don t need to be initialized Forever loop until the user press any key while 1 tmpCnt Set DO Value printf n nSet and Get All Channels Test n if tmpCnt 2 0 dov 0 else dov Oxf if SetDO EB50_ID AllChannels 0 dov 0 printf Set DO value 0x X dov ADAM 4500 Series User s Manual 5 37 Chapter 5 Programming and Function Library printf press any key to continue n getch if GetDIO EB50 ID AllChannels 0 amp div 0 printf DI value is Ox X n div j else printf Get DI failed j else printf Set DO failed n printf n nSet and Get Sigle Channel Test n if tmpCnt 2 0 dov 0 else dov 1 i SetDO EB5O ID SingleChannel 1 dov 0 printf Set DO channel 1 value X dov printf press any key to continue n getch if GetDIO EB50 ID SingleChannel 1 amp div 0 printf Channel 1 DI value is x n div else printf Get DI failed j else printf Set DO failed n printf press Q to quit the other key to continue An c getch if c q c Q break 5 38 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 3 3 Communication Functions A4 COMM LIB SIO Open Syntax CHAR SIO_Open UCHAR i ucPort Description Initializes the COM port and interrupt service routine before other function calls use the COM port Parameter De
6. iState ADAMTCP_ModServer_Update second step if iState if has message show the data at address 40001 if ore_data Share Mem 0 adv_printf 40001 is X n Share Meml 0 notice printf will decrease server performance pre data Share Mem 0 j 5 112 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMTCP ModServer Release Syntax void ADAMTCP ModServer Release void Description Release Modbus TCP Server Parameters None Returned value None ADAM 4500 Series User s Manual 5 113 Chapter 5 Programming and Function Library 5 4 6 Socket Functions SOCKET LIB TCP IP SOCKETS API Overview This section describes the SOCKETS API which is compatible with the BSD Sockets API and also the Winsock API The definitions and prototypes for the C environment are supplied in SOCKET H while the implementation of the C interface is in SOCKET C The SOCKETS API is implemented as a layer on top of the Compatible API CAPI and provides an interface to the socket and name resolution facilities provided by the Datalight DOS SOCKETS product It also provides the database functions of BSD Sockets and Winsock A socket is an end point for a connection and is defined by the combination of a host address also known as an IP address a port number or communicating process ID and a transport protocol such as UDP or TCP Two connected SOCKETS using the same transport protocol
7. do something else here 5 48 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library else if RecvMode UnBlock Mode while nT otalByte lt RecvDataLen if nByte SIO RecvBytes tmpCOM UnBlock Mode RecvDataLen amp Data nTotalByte gt 0 j else nTotalByte nByte printf Error Receive n return nTotalByte 0 else if SIO_GetAvaiSendBuf tmpCOM gt RecvDataLen if SIO_SendBytes tmpCOM RecvDataLen Data RecvDataLen Idx RecvDataLen if Data ldx 1 0x0d Mode 0 Idx 0 ADAM 4500 Series User s Manual 5 49 Chapter 5 Programming and Function Library else printf Error Send n return j j else printf do something send do something else j SIO Close tmpCOM 5 50 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO MakeCheckSum Syntax UINT SIO MakeCheckSum UCHAR i ucDataBuf UINT i uiLen Description Calculates the checksum of the string or data array i ucDataBuf Parameter Description i ucDataBuf The string or data array for which a user wants to calculate the checksum uiLen The length of the string or the data array Return value The checksum value of the data array buffer Remarks None ADAM 4500 Series User s Manual 5 51 Chapter 5 Programming and Function Library SIO MakeCRC16 Syntax UINT SIO MakeCRC16 UCHAR i ucDataBuf UINT i uiLen Description C
8. e E NN a hs BG P X E x gt The decimal point is set by bit D7 1 Above this table 7 5EGMENT CHARACTER is the value showed on LED displayed and REGISTER DATA is setting value When the bit D7 is 1 bitd bit6 can be arbitrary bumber the value will be a decimal point For example data 3 hex can show the number S of the LED character And data 83 can show the number 3 of the LED character Return value None Example Refer to C Program Files Advantech ADAM 4500 Series Utility Source Example Basic_Function ex1 C for this example include 4500drv h include dos h 5 30 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library void main void unsigned char data 5 1 2 3 4 5 int i display init 1 printf please input 5 numbers 0 9 n for i20 i 5 i4 4 scant d amp data i if data i O data i gt 9 printf input error exit exit 0 display digit amp data 1 5 exit 0 Remarks None ADAM 4500 Series User s Manual 5 31 Chapter 5 Programming and Function Library BatteryStatus Syntax int BatteryStatus void Description Check the power status of battery which is used by battery backup SRAM Parameter None Return value 0 The power ststus of battery is almost run out lt is strongly recommend to change a new battery 1 The power status of battery is still normal Example
9. ASoSeogsg Figure 2 12 Ethernet Connection ADAM 4500 Series User s Manual 2 11 Chapter 2 Installation 2 4 Software Installation ADAM 4500 Series Controller comes with a Utility CD containing ADAM Product Series Utilities as system configuration tool While you Insert the CD into the CD drive e g D of the host PC the Ultility software setup menu will start up automatically Click the ADAM 4500 Series icon to execute the setup program and there will be a Utility executive program installed in your host PC See Chapter 3 I O Configuration and Program Download for the detail operation 2 12 ADAM 4500 Series User s Manual Program Download Chapter 3 Program Download This chapter explains how to use the ADAM 4500 Series Utility to configure and download application programs 3 1 System Hardware Configuration Before the system configuration you will need to setup the environment as mentioned in Chapter 2 1 System Requirements 3 2 Install Utility Software on Host PC ADAM 4500 Series Controller comes with a Utility CD containing ADAM Product Series Utilities as system configuration tools 1 Insert the ADAM Utility CD into the CD drive of the host PC and the Utility software setup menu will start automatically Click the Install Utility button to install ADAM Series Utility Advantech ADAM eAutomation I O Solution Lea ADAM is the best answer to t monitoring and control appli
10. Project Options Window Help Options _ any lt e Small int Sendflarm 2 edi int Makefllarm int count void maintvoi amp Assume 55 Equals DS unsigned char dovi 43 47 Fi Help Use small memory model 64K for code 64K for static data Figure 5 4 Select Small Model while using S LIB 5 1 5 Limitations Certain critical files are always kept in flash ROM such as operating system BIOS and monitoring files The ADAM 4500 Series Controller provides an additional 1MB flash disk as drive D There is up to 960KB free space for user s application program As some additional system files and network utilities for ADAM 4500 Series Controller is distributed on drive D the free space for user s application program should be less than 960KB Besides there are 256KB flash memory and up to 384KB battery SRAM for user s applications which can be accessed by function library Chapter 5 Programming and Function Library Warning The free space of flash disk is not suitable for frequently creating and deleting files such as periodic data logging application because the DOS FAT file system is probably destroyed by critical operations while the disk is almost full The better way is to take the operations on battery backup SRAM 5 1 6 Programming the watchdog timer The ADAM 4500 Series Controller is equipped with a watchdog timer function that resets the CPU or generates an interrupt if processing comes to a standstill for
11. 1 Watchdog timer reset mode if watchdog timer is enable it have to be cleared at least once every 1 6 seconds or the system will reboot Please refer section 5 3 1 to see how to use function library to configure watchdog timer 2 NMI Non maskable interrupt reset mode once the NMI is activated the system will reboot 3 Non reset mode there is no reset mode set for system The default setting of watchdog timer is watchdog timer reset mode Jumper settings are shown below JP2 Reset Mode Setting i watchdog reset NMI reset non reset Figure 2 2 Jumper of Reset Mode Battery Backup RAM Setting Jumper JP5 on the CPU card lets you configure the battery backup for SRAM is Enable or Disable The default setting of battery backup is Enable Jumper settings are shown below JPS Battery Backup RAM Enable Disable Figure 2 3 Jumper of battery backup 2 4 ADAM 4500 Series User s Manual Chapter 2 Installation Guidelines COM4 Communication Mode Selection Setting The communication mode of COMA is setting by the Jumper JP6 and JP7 Please refer to Figure 2 9 to set the communication mode The default setting of COM4 is Programming port RS 232 mode for program download You can also set COM4 as RS 485 mode Jumper settings are listed below Je Dm eje Pe rime vj I mele P7 Ym lore RS 485 Programming Port Figure 2 4 Jumper of COM4 communication mode selection 2 3 System Wiring and Connections Th
12. 4 64 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions if hasMessage if numbytes recv remoteSocket sidx buf sizeof buf 0 SOCKET ERROR ReleaseClient sidx j else if numbytes gt 0 printf Server receive s buf if tmpcount962 2 0 str ACK n else str A C Kw if numbytes 0 ReleaseClient sidx else if send remoteSocket sidx str strlen str 0 SOCKET ERROR ReleaseClient sidx j memset buf 0 sizeof buf tmpcount 4 4 if Qtmpcount 100 tmpcount l WaitSocketCount sidx 0 j j else WaitSocketCount sidx if WaitSocketCount sidx 10000 timeoutRelease TRUE ADAM 4500 Series User s Manual 4 65 Chapter 4 Guidelines for Network Functions ReleaseClient sidx j j j j return 0 j int Host WaitForClient int WaitSocket int i iWaitMilliSec fd set FdSet struct timeval waitTime FD ZERO amp FdSet FD SET WaitSocket amp FdSet waitTime tv sec i iWaitMilliSec 1000 waitTime tv usec i iWaitMilliSec 1000 1000L if select 0 amp FdSet NULL NULL amp waitTime 0 return TRUE return FALSE j void ReleaseClient int idx_so int sidx sidx2 sidx idx so if timeoutRelease if send remoteSocket sidx Connetion timeout you are going to be disconnectedN n 53 0 1 perror send if remoteSocket sidx INVALID_SOCKET if
13. 8 x File Help Local System _ ADAM 4500 Series EH Saj ef 25 7 EE Es e zia fcomi z Name Size Type Modified Application FTPD EXE 45KB Application 2006 07 14 6 00 00 AM 44KB Application HrTPD EXE 50KB Application 2006 0714 6 00 00 AM 45KB Application HTTPDEMO EXE 28KB Application 2006 0714 6 01 00 AM 50KB Application HTTPFTPD EXE 63KB Application 2006 07 4 4 5 03 00 4M 28KB Application B3KB Application 1KB HTML Do a 7 object s 257 5 KB 4 object s 183 9 KB 627 200 bytes free Directory of D WEBROOT lt DIR gt 07 14 2006 Exe lt DIR gt 07 14 2006 HITPFTPD EXE 64 256 07 14 2006 HTTPD EXE 50 432 07 14 2006 HITPDEMO EXE 28 160 07 14 2006 EXE 45 440 07 14 2006 6 file s 188 288 bytes 627 200 bytes free D WEBROOT gt A start 2 Y ii adamaso0 Sw 6 13PM 4 10 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 9 Put switch into Normal mode and then reboot Type cd webroot to enter Webroot directory Type httpd r to run HTTPD EXE at resident fill ADAM 4500 Series Utility Yer 1 13 l x File Help eaj C Program Files Advantech 4DAM 4500 Series UtilityiSo i Name Size Type Modified Application FrPD ExE 45KB Application 2006 07 14 6 00 00 AM Application HTTPD EXE 50KB Application 2006 0714 6 00 00 AM Application HrTPDEMO EXE 28KB Application 2006 0714 6 01 00 AM Application HTTPFTPD EX
14. 9 Run IE on Host PC type URL http 10 0 0 1 index htm and login in by entering user name and password 81 x File Edit View Favorites Tools Help a Back GD ix B A J2 Search Se Favorites Ol oA Address http 10 0 0 1 index htm EJo Links pa E Opening page http 10 0 0 1 index htm O i Internet A start W EJ lb Adam4soo about blank Microso wm 10 15 AM Note 10 0 0 1 is the default IP of ADAM 4500 Series Controller and refers to SOCKET CFG under ADAM 4500 Series Utility Source Drive_D Default_files Conf to get real IP address You can refer to SOCKET UPW for user name and password 6 You should be able to see ADAM 4500 Series Controller built in I O board ID as shown by figure below 4 12 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions e http 10 0 0 1 index htm Microsoft Internet Explorer 4 I 81 xi File Edit view Favorites Tools Help O Back v v ix B A J2 Search Sp Favorites O e Address http 10 0 0 1 index htm z co us The extension board ID is 0x10 E Done ef Internet A start S Y Wii Adam4soo IE http 10 0 0 1 index Sw 6 17PM ADAM 4500 Series User s Manual 4 13 Chapter 4 Guidelines for Network Functions The following figure is the software architecture of HTTP Server function The HTTP Server is built in in the ADAM 4500
15. Chapter 5 Programming and Function Library ADAMTCP ReadHoldingRegs Syntax int ADAMTCP ReadHoldingRegs SOCKET SO int WaitMilliSec int Slave Addr int Startlndex int TotalPoint int ByteCount char wData Description 03 HEX command of Modbus TCP function code Parameters Desceription SO The socket connected to Modbus TCP server WaitMiliSec Set duration msec unit for the response from Modbus TCP server Slave_Addr Slave address StartIndex Starting address TotalPoint No of points ByteCount Byte count wData Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example This example demonstrates how to use ADAMTCP_ ReadHoldingRegs to query remote Modbus TCP module such as ADAM 5000 TCP And it queries all channels of ADAM 5024 inserted in Slot 3 on the ADAM 5000 TCP if errno ADAMTCP_ReadHoldingRegs amp SO_4500 50 0x01 0x19 0x08 amp DataByteCount HostData lt 0 perror ADAMTCP_ReadHoldingRegs n adv_printf errno is d n errno 5 102 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMTCP Disconnect amp SO 4500 return O j ADAM 4500 Series User s Manual 5 103 Chapter 5 Programming and Function Library else i adv_printf Adam 5
16. UP ADAM 4500 Series Utility Ver 1 14 File Help i81 xl Local System TCLIENT EXE TCP Client c TCP Server c f TSERVER EXE E TServer PRJ UCLIENT EXE E UDP Client c Z UDP Server c 7 USERVER EXE ADAM 4500 Series Applical CONF C File WEBROOT C File fs AUTORUN BAT Applical 7 4x8786 coM PR File CFGIO EXE Applical DEMORS EXE C File DEMOTS EXE C File SOCKETP EXE Applical TSERVER EXE ima USERVER EXE H 9 object s 159 4 KB E xs i8 valcom 1KB 13KB 35KB 41KB 51KB 48KB 35KB 34KB File Folder File Folder MS DOS B MS DOS A Application Application Application Application Application Application Name Size Type Moditiea 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 4M 2006 07 25 6 01 00 4M 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 AM 2006 07 25 7 01 00 AM 2006 07 25 6 01 00 4M 2006 07 25 6 01 00 AM 2006 07 25 7 02 00 AM 2006 07 25 7 03 00 AM 10 object s 254 8 KB 587 776 bytes free AUTORUN BAT AX8796 COM CFGIO EXE SOCKETP EXE DEMOTS EXE DEMORS EXE TSERVER EXE USERVER EXE 10 file s 4 Build ADAM 4500 128 13 184 352320 48 896 51 456 41 344 35 712 34 816 2 UCLIENT EXE 07 25 2006 6 11p 07 25 2006 6 11p 07 25 2006 6 11p 07 25 2006 6 11p 07 25 2006 6 12p 07 25 2006 6 19p 07 25 2006 7 11p 07 25 2006 7 24p 07 25 2006 7 34p 60
17. ejoj sem sjm ejafos s LAE Appkcaton aD IED HTML Do 5 200 E E 7 obits 287 3 Kl object s tO Sh eG bytes free tiTransferriog Film gt ipet ACE for EOT gt Volume in drive D bas na label Volume Serial Humber iz 2466 1HEL Directory of D WEBHROUOT DIR u ui zu amp Hillp d NTR 07 03 2006 A illp HIIPFIPD EXE 64 256 OF 03 2006 B 12p J file s 64 256 bytes fol 616 bytes rec Lal Esat 5 L3 ng Adan rsuo Wi 19 PM ADAM 2500 Series Utility Ver 1 13 sla x Lead Gytha AAS 5 echt IER Appleton DAMAO eren exe 44H Apedcahon MRO AM L4 dk Apphesten 4H 30004 Eurer exe EH Appian OROA 00 AMI i HON Appii 4702 72004 L1 DOCU Appii 4 13 2004 I1 FD Appian E120 I1 EED Appen 4 704 igi IED HTMLDo BAIE i J xi objectis 27 3 Kl 2 obiectis 157 1 KD GA Enters Free ume im drive D has Volume Serial Number is 7466 i ectory of D wEBROOT COLES y 4 27006 DIA 17 700R HIIPEIPD EXE b4 256 OF FTPII EXE 45 440 07 4 File e 109 695 bytes 706 040 bytes rec DO WEBROOT iistart 2 W C ag Adamas Wi 9 20PM 4 6 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 2 Put switch into Normal mode and then reboot Type cd webroot to enter directory Type ftpd r to run FTPD EXE at resident IRI ADAM 18 xl File Help el ese wm rz E weercor_ o GQ Name Size Type modified 38KB Appl
18. Chapter 4 Guidelines for Network Fu File Help Local System ADAM 4500 Series m 2 ga covo i Nam Size Type Modified 1 TCLIENT EXE Application 2006 07 725 CONF File Folder 1980 01 01 12 00 00 PM E TCP_Client c 4KB C File 2005 08 08 WEBROOT File Folder 1980 01 01 12 00 00 PM E TCP_Server c 8KB C File 2005 08 08 fs AUTORUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM Ir TSERVER EXE 35KB Application 2006 07 25 xer9s COM 13KB MS DOS A 1980 01 01 12 00 00 PM TServer PRJ 5KB PAJ File 2004 08 1 crFoio EXE 35KB Application 1980 01 01 12 00 00 PM 1 UCLIENT EXE 35KB Application 2006 07 25 f DEMORC EXE 23KB Application 1980 01 01 12 00 00 PM B UDP Client c 4KB CFile 2005 08 08 f DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM UDP_Server c 4KB C File 2005 08 08 SOCKETP EXE 48KB Application 1980 01 01 12 00 00 PM UusERVER EXE 34KB Application 2006 07 25 imi TCLIENT EXE 35KB Application 1980 01 01 12 00 00 PM ni 9 object s 159 4 KB 9 objects 198 9 KB 644 608 bytes free 01 01 1980 WEBROOT lt DIR gt 01 01 1980 12 05a AUTORUN BAT 128 01 01 1980 12 05a AX8796 COM 13 184 D1 01 1980 12 05a CFGIO EXE 35232080 DI 0I 1380 12 053 SOCKETP EXE 48 896 01 01 1980 12 05a DEMOTC EXE 48 256 01 01 1980 12 10a DEMORC EXE 22 784 01 01 1980 12 00a TCLIENT EXE 35 072 D1 01 1980 22 08a 9 file s 203 648 bytes 644 608 bytes free 4 60 ADAM 4500 Series User s Manual nctions lB x
19. Description Sets a socket option Parameters Description SO A descriptor identifying a socket level The level at which the option is defined the only supported levels are SOL SOCKET and IPPROTO_TCP 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 optlen The size of the optval buffer Return Value If no error occurs setsockopt returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed 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 ENETRESET Connection has timed out when SO KEEPALIVE is set ENOPROTOOPT The option is unknown or unsupported In particular SO BROADCAST is not supported on sockets of type SOCK_STREAM while SO DONTLINGER SO KEEPALIVE SO LINGER and SO OOBINLINE are not supported on sockets of type SOCK DGRAM ENOTCONN Connection has been reset when ADAM 4500 Series User s Manual 5 167 Chapter 5 Programming and Function Library ENOTSOCK The descriptor is not a socket 5 168 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Remarks setsockopt sets the current value for a socket option associated with a socket of any type in any state Although
20. Refer to Release All 5 26 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Release All Syntax void Release All Description Releases all timer resources of the ADAM 4500 Series system Parameter None Return value None Remarks None Example include 4500drv h void main Int idx Initializes the timer built into the 80188 microprocessor Timer Init Sets time interval of the timer to 1 second a idx Timer Set 1000 Checks whether the timer has timed out a while tmArriveCnt idx 0 user can attend to other tasks t adv printf test j Resets the current timer to its initial state Timer Reset idx Releases all timer resources Release_All ADAM 4500 Series User s Manual 5 27 Chapter 5 Programming and Function Library WDT clear WDT disable WDT enable Syntax void WDT clear void void WDT disable void void WDT enable void Description WDT clear Clear watchdog timer WDT disable Disable watchdog timer WDT enable Enable watchdog timer When the watchdog timer is enabled it will have to be cleared at least once every 1 6 seconds or the system will automatically reboot The watchdog timer default value is disable Parameter None Return value None Example include 4500drv h void main void Int I WDT_enable for i 0 i lt 100 i put your code in Here WDT clear p
21. Return Value If no error occurs gethostname returns 0 otherwise it returns SOCKET ERROR and a specific error code is returned in errno Error Codes EFAULT The AddressLen parameter is too small ENETDOWN SOCKETS has detected that the network subsystem has failed Remarks This routine returns the name of the local host into the buffer specified by the pszName parameter The host name is returned as a null terminated string The form of the host name is dependent on the SOCKETS configuration file However it is guaranteed that the name returned will be successfully parsed by gethostbyname See Also gethostbyname 5 184 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library getprotobyname Syntax struct protoent getprotobyname const char pszName Description Gets protocol information corresponding to a protocol name Parameters Description pszName A pointer to a protocol name Return Value If no error occurs getprotobyname returns a pointer to the protoent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO DATA Valid name nodata record of requested type Remarks getprotobyname returns a pointer to the following structure which contains the name s
22. S AUTORUN BAT 1KB MS DOSB 2006 0619 6 02 00 AM wu ADV SRAMDRV Removabl 74x8786 coM 13KB MS DOS A 2005 0649 6 02 00 4M G Control Panel System Fol CFGIO EXE 35KB Application 2006 0649 6 02 00 AM ed Doct t File Folder 3 1 2006 3 REID EXE 7KB Application 2006 0619 6 03 00 AM Sha C My Docum File Folder 6 16 2006 7 sockETP EXE 48KB Application 2006 05 19 6 03 00 AM 7 object s 0 byte s jJ object s 101 8 KB 700 928 bytes free 06 19 2006 06 19 2006 06 19 2006 06 19 2006 06 19 2006 06 19 2006 06 19 2006 104 192 bytes 700 928 bytes free ANAARAAHE 4 start 5 Y iii adamasoo mS 6 43PM 8 Click the Adam 4500 Configuration button for configuring network such as IP address Gateway and DNS FTP HTTP server settings and performing system initialization function Refer to section 3 4 and 3 5 for more amp C 5 EEE Mv Computer i a Adam 4500 Series Configuration I z Adam 4500 Series System Conf amp Init s UND 3072 3074 System Configuration um Removable Disk IP DHCP vw Removable Disk Static IP DHCP Obtain DNS address automatically ADV SRAMDRV g Control Panel Ae I J J Primary DNS E ared Documer Gateway E E o 1 ocumer Update FTP amp HTTP Configuration FTP HTTP ID ID Password Password 7 object s lo byte Rights Change Dir Rights G
23. The value requested by the user Example include 4500drv h void main void unsigned char sec 0 min 0 hour 12 adv printf Time 02d 02d 02d n GetRTCtime RTC_hour GetRTCtime RTC min GetRTCtime RTC sec adv printf Set current time 12 00 00 SetRTCtime RTC_sec sec SetRTCtime RTC_min min SetRTCtime RTC_hour hour adv printf Time 02d 02d 02d n GetRTCtime RTC_hour GetRTCtime RTC min GetRTCtime RTC sec j Remarks None 5 16 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library LED init LED OFF LED ON Syntax void LED init void void LED OFF int which led void LED ON int which led Description Turns LED lights on and off The LED I O port must be initialized first It will take a little time for the light to stabilize following the signal for the turning on and turning off of the light Parameter The PWR LED which led The RUN LED COMM The COMM LED Return value None Example include 4500drv h void main void LED init flash COMM led while 1 LED ON COMM ADAMdelay 500 LED OFF COMM j Remarks None ADAM 4500 Series User s Manual 5 17 Chapter 5 Programming and Function Library EraseSector ProgramByte ProgramSector Syntax unsigned short EraseSector unsigned long ulBase unsigned short ProgramByte unsigned long ulAddress BYTE byte unsigned short ProgramSector unsigned long ulAddress s unsigned ch
24. e Click the Advantech Image Worker button to perform the restore function HIT ADAM 4500 Series Utility Ver 1 13 i 2181 x File Help se UNO 3072 3074 Local Disk CONF File Folder 2006 0646 1 00 00 AM w Removable Disk Removabl O WwEBROOT File Folder 2006 0616 1 00 00 4M w Removable Disk Removabl fS AUTORUN BAT 1KB MS DOS B 2006 0616 1 00 00 AM w ADV SRAMDRY Removabl P axe796 COM 13KB MS DOS A 2006 0616 1 00 00 AM e Control Panel System Fol CFGIO EXE 35KB Application 2006 06 16 1 00 00 AM Shared Documents File Folder 3 1 2006 3 SOCKETP EXE 48KB Application 2006 0646 1 00 00 AM My Documents File Folder 6 16 2006 7 objectis o byte s 6 objects los 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D CONF DIR 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 ee AX8796 COM 13 184 06 16 2006 EET PA CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free m d start S 3 W iii adamasoo S ww 3 11PM ADAM 4500 Series User s Manual 3 27 3 Chapter 3 Program Download Click the Restore Image button FII ADAM 4500 Series Utility Ver 1 13 _ amp x File Help Local System ADAM 4500 Series Alafo z Se LINO 3072 3074 Local Disk 123 File Folder 2006 05 19 8 02 00
25. i lt InterruptNumber gt m lt MemorySize gt n lt MaximumConnections gt a lt ScreenX gt lt ScreenY gt v lt ScreenBufferSegmenb lt ScreenBufferOffset gt k Remarks ScreenX ScreenY Description Display help screen Run server in TSR mode Display server status Enable htaccess directory level authentication Unload if resident Close listen Do not start remote console allow old type Spawning CGI Passive mode Interrupt number for cgi API Set memory size Number of simultaneous connections Set screen aspect Set video buffer address hex Unload and abort all active connections The width and height of the screen area to serve for the remote console session These values default to 80 and 25 respectively ScreenBufferSegment S creenBufferOffset Together a pointer to the top left corner of the display memory to serve for the remote console session These values default to B000 and 0000 respectively monochrome display adapters and to B800 and 0000 respectively for color display adapters MemorySize The maximum amount of memory available to the server The default value is 32K The value of m can range from 8192 to 63472 MaximumConnections The maximum number of simultaneous connections allowed by the server ADAM 4500 Series User s Manual 7 7 Chapter 7 HTTP and FTP Server Application InterruptNumber The interrupt number to access the CGI API http port HTTP port
26. iTotalByte Byte Count i szDatal Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example HostData 0 0x12 HostDatal 1 0x56 HostData 2 0x38 HostData 3 0x09 I IADAMRTU PresetMultiRegs COM 1 0x02 0x64 2 4 HostData adv printf err code is d n Error_Code adv printf fail send return else adv printf Success ADAM 4500 Series User s Manual 5 79 Chapter 5 Programming and Function Library ADAMRTU PresetSingleReg Syntax bool ADAMRTU PresetSingleReg int iPort int i iAddr int i iReglndex inti iData Description 06 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave Address i iReglndex Register Address iData Preset Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example if ADAMRTU_PresetSingleReg COM1 0x02 0x68 0x1234 adv_printf err code is d n Error_Code adv printf fail send return else adv printf Success 5 80 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMModbusRTU Write Syntax bool ADAMModbusTCP Write SOCKET SO int WaitMilliSec int Slave Addr unsigned long i iStartAddr unsigned long i iEndAddr unsigned char i szData Description Presets values or forces coils into a sequence of holding registers 4X references or a se
27. recvfrom SO 4500 buf sizeof buf O struct sockaddr amp From Addr amp From_Size 1 perror recvfrom exit I buf numbytes 0 printf got Ack packet s from Ys n buf inet ntoa From Addr sin addr closesocket SO 4500 return 0 j ADAM 4500 Series User s Manual 4 79 Chapter 4 Guidelines for Network Functions 4 10 FTP Client 1 Put switch into Initial mode Download FTP EXE under ADAM 4500 Series Utility Source Drive_D Extension_files WebRoot onto drive D under Webroot directory f ADAM 4500 Series Utility Yer 1 14 EB 81 x File Help Local System ADAM 4500 Series T afa a Alafon z C Program Files Advantech 4DAM 4500 Series UtilityiSo WEBROOT Name Size Type Modified Nam Size Type Modified DAM E 38KB Application 2004 05 27 44KB Application 2006 07 26 11 05 00 AM 44KB Application 2004 04 1 HTTPFTPD EXE 63KB Application 2006 07 25 6 01 00 AM 45KB Application 2004 04 71 5OKB Application 2004 04 1 50KB Application 2004 06 17 pd ex 63KB Application 2004 04 1 amp dam HTM 1KB HTML Do 2004 06 0 Suu objects 287 3 KB 2 object s 106 5 KB 542 720 bytes free cd WEBROOT dir Volume in drive D has no label Volume Serial Number is 0C22 19E1 Directory of D WEBROOT lt DIR gt 07 25 2006 we take aes lt DIR gt 07 25 2006 6 1ip HITPFTPD EXE 64 256 07 25 2006 bo 2p FTP EXE 44 800 07 26 2006 1
28. should be called By default a socket may not be bound see bind to a local address which is already in use On occasions 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 SOCKETS 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 ADAM 4500 Series User s Manual 5 169 Chapter 5 Programming and Function Library socket option for the socket before 5 170 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 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 An application may request that SOCKETS enable the use of keep alive packets on TCP connections by turning on the SO KEEPALIVE socket option If a connection is dropped as the result of keep alives the error code ENETRESET is returned to any calls in progress on the socket and any subsequent calls will fail with ENOTCONN The TCP NODELAY option disables t
29. 20D Dar ti wipati Di ea 1 8 wp fm FwB Ajpk pr E li ARD Ape hir i ic c Ei 5 obetia fe MTS amp objeriia Fe s mn ee B odilein D bytes a oh 595 456 bviem Bie ADAM 4500 Series User s Manual 4 25 Chapter 4 Guidelines for Network Functions 3 Create MAIL txt on the left window on the host PC Edit the content of this file When you finish the editing save the file on Host PC This file is the content file which will be sent by e mail later AL hh lS Seriea Laity ier 1 12 Png Per eens A 450 Seen Ly ae See OL ot ae ee Pe a A 100004 SALE 2 E OO AM 2006 0 EB 10 00 00 AM bs amp LILILELILILILIE e Babii L1 mi HATE al acad dar Tad Documents 7 tat Vnlumae in drive D ham mc Labo Volume Serial Humber am zA5E 12 BNG Directory of Bis CONF DIES urz 1u FENKT Dike Gf L0 2006 11 Oda AUTONHUM HAT 1280 OF 10 2006 11 044 ADOT OG OOH 13 317 07 10 2006 11 04a CEGICO EXE 45 320 U7 1HU z2 U0b 11 04 SOCKETE EE aH 896 u7 1Hu 2Uub 11 044 HAIL cDths OF 1b 2006 2 380p 7 file s T bb4A byten G96 456 bhykem rec a 4 Download MAIL txt onto drive D under MAIL directory ADAM A400 Series Uillity Ver 1 13 ETEC amp amp ta S es fim Hanes SOOO 17 08 00 SEE Apakan 2004 04713 7 10 00 4 JEE Apnheanon 2004 04 13 7310 0X HEH Appkeeien 2004 04713 7 10
30. Chapter 5 Programming and Function Library htons Syntax u short htons u short usHostshort Description Converts au short from host to network byte order Parameters Description sHostshort A 16 bit number in host byte order Return Value htons returns the value in network byte order Remarks This routine takes a 16 bit number in host byte order and returns a 16 bit number in network byte order See Also htonl ntohl ntohs 5 138 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library inet addr Syntax unsigned long inet addr const char pc Description Converts a string containing a dotted address into an in_addr Parameters Description pc A character string representing a number expressed in the Internet standard notation Return Value 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 NONE Remarks This function interprets the X character string specified by the pc 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 Internet addresses are returned in network order bytes ordered from
31. O0 AJ IER Appin 2004047713 2 10 OO AUI Tabit 175 1 XE 1 abjec Ld Estela Eden etd betes Fee 7 lilnim lU byten E 13 45 byten Tram C stranniar 2 D eMAILVWBAIL txt zrTranmimrring File tx t fek ACK for BT gt cud iA I1 dir Volumm in drive D has m c Label Volume Serial Humber im 245E 1709 Directory of D sBAIL i DIE Uf 1H Z2U p z d0p l DIES OF 1b F006 2 Jip HAIL TXT 17H 07 18 7006 2 31p 3 file s 12H bytes 694 904 byles rec 4 26 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 5 Download MAKEMAIL EXE and SENDMAIL EXE under ADAM 4500 Series Utility Source Drive_D Extension_files onto drive D under MAIL directory ADM 4740 Series Ligility Yer 1 13 iL CORA 2 OLD MI Io Text u HEE Appkeeie 2004 04013 7 100 00 AJ JEH Appkeatien 20047047713 7 T0 OC AU Tabii 178 1 amp 1 phpectis Ld bytea Eden etd betes fren lilnim D byten ini bpkbmm irer e Stransiow 2 OLD SMATESMATE txk zTranminrring Ki tomb ACK tor wor di ere aa Fokus in drive D ham mc Label Volume Serial Humber im 245E 12D3 Directory of D sBAIL DIE Urz lu 2 0b0 z JOp C DINS Df 1H Ulb 2 Jup HATIL TET 120 D7T 1H 2U1f 23 31pm 3 filets 12H betes Gdi 44 byes reo 6 Using AMAIL PRJ to Build AMAIL EXE under ADAM 4500 Series Utility Source Example mail directory and download AMAIL EXE onto drive D under WEBROOT
32. SO OOBINLINE are not supported on Sockets of type SOCK DGRAM ENOTSOCK The descriptor is not a socket 5 134 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Remarks getsockopt retrieves the current value for a socket option associated with a socket of any type in any state and stores the result in pcOptval 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 pcOptval The integer pointed to by piOptlen should originally contain the size of this buffer on return it 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 The following options are supported for getsockopt The Type identifies the type of data addressed by optval The TCP NODELAY option uses evel IPPROTO_TCP all other options use level SOL SOCKET Value Type Meaning Default SO ACCEPTCONN BOOL Socket is listen ing FALSE SO BROADCAST BOOL Socket is configured FALSE for the transmission of broadcast messages SO DEBUG BOOL Debugging is enabled FALSE SO_DONTLINGE
33. and protocol number which correspond to the given protocol pszName struct protoent char p name char p aliases short p proto ji The members of this structure are Element Usage p name Official name of the protocol p aliases A NULL terminated array of alternate names p proto The protocol number in host byte order ADAM 4500 Series User s Manual 5 185 Chapter 5 Programming and Function Library The pointer which is returned points to a structure which is allocated by the SOCKETS library The application must never attempt to modify this structure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls See Also getprotobynumber 5 186 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library getprotobynumber Syntax struct protoent getprotobynumber int number Description Gets protocol information corresponding to a protocol number Parameters Description number A protocol number in host byte order Return Value If no error occurs getprotobynumber returns a pointer to the protoent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO DATA Valid name nodata record of r
34. gt ECHO OFF CMON Initial Mode ER 2 Run DEMORC EXE and you will find the connection is successful as following figure You will also find the LEDs of ADAM 4056S periodically switch ON OFF by the command F ADAM 450u Simie Sl Vauy pe als gy E x V ADAM 4500 Series EST C n oe c E iJ B z a JME C Program Files Advantechi 4D4M 4500 Series LltilityYSo v Name Size Type Modifier a Name Size Type Modified B 45D0DRV H 12KB H File 2 22 20 CONF File Folder 1980 01 01 12 00 00 PM E DemoRC c 1KB C File 2423 20 WEBROOT File Folder 1980 01 01 12 00 00 PM m DEMORC EXE 23KB Application 7725 20 S AUTORUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM si DemoRC PRJ 5KB PR File 7 25 20 4x8796 COM 13KB MS DOS A 1980 01 01 12 00 00 PM B DemoRS c 1KB CFile 7 24 2C E craio EXE 35KB Application 1980 01701 12 00 00 PM DEMORS DSK 3KB DSK File 7 25 20 DEMORC EXE 23KB Application 1980 01 01 12 00 00 PM DEMORS EXE 41KB Application 7 25 20 DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM s DemoRS PRJ 5KB PAJ File 7725 20 SOCKETP EXE 48KB Application 1980 01 01 12 00 00 PM DemoTC c 3KB CFile 6 21 420 DEMOTC EXE 48KB Application 7 25 20 E DemoTC PRJ 5KB PR File 7 25 20 DemoTS c 2KB C File 7 24 20 DEMOTS DSK 3KB DSK File 7 18 20 FAINFMNTS FXF RIKR nnlicatinn 7527S 7 objects 230 0 KB 8 object s 164 6 KB 679 936 bytes free 789 C gt E
35. high voltage lines are for reducing the cost of moving electrical power from one place to another Wire Impedance The wire Impedance will consume the power Figure C 6 wire impedance ADAM 4500 Series User s Manual C 7 Appendix C Grounding Reference C 1 5 Single Point Grounding Single Point Grounding a P ADAM IADAM DAM kamia by k 4021 E s s 1 1 E 3 Lo 416y 418y 20Y 22 0 0 0 9 Those devices will influence each other with swiftly load change Figure C 7 Single point grounding 1 e Whats Single Point Grounding Maybe you have had an unpleasant experience while taking a hot shower in winter Someone turns on a hot water faucet somewhere else You will be impressed with the cold water The bottom diagram above shows an example of how devices will influence each other with swift load change For example normally we turn on all the four hydrants for testing When you close the hydrant 3 and hydrant 4 the other two hydrants will get more flow In other words the hydrant cannot keep a constant flow rate C 8 ADAM 4500 Series User s Manual Appendix C Grounding Single Point Grounding 18V 20V 22V 22V 22V 22V Power Supply More cable but more stable system Figure C 8 Single point grounding 2 The above diagram shows you that a single point grounding system will be a more stable system If you use thin cable for powering these devices the end device
36. lt DIR gt 07 14 2006 He ale HITPFTPD EXE 64 256 07 14 2006 5 d2p HTTPD EXE 50 432 07 14 2006 6 06p HITPDEMO EXE 28 160 07 14 2006 6 12p FTPD EXE 45 440 07 14 2006 6 08p ADAM EXE 30 464 07 14 2006 6 22p 7 file s 218 752 bytes 596 480 bytes free mE start ey iii Adam4500 S wh 6 23PM 4 18 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 Put switch into Type cd webroot httpd r to run Normal mode and then reboot to HTTPD EXE at resident fill ADAM 4500 Series Utility Yer 1 13 File Help Local System Application 44KB Application 45KB Application 50KB Application 28KB Application B3KB Application 1KB HTML Do object s 257 5 KB D WEBROOT gt httpd r E enter Webroot directory Type 15 xl ADAM 4500 Series Name Size Type Modified ADAM EXE 30KB Application 2006 0714 6 02 00 AM FTPD EXE 45KB Application 2006 0714 6 00 00 AM 7 HrTPD EXE SOKB Application 2006 07 4 6 00 00 4M HTTPDEMO EXE 28KB Application 2006 0714 6 01 00 AM HTTPFTPD EXE 63KB Application 2006 0714 5 03 00 4M WEBADAM HTM 1KB HTML Doc 20060744 6 02 00 AM 6 object s 214 1 KB 595 968 bytes free Sockets HITP RC Server v6 22 Revision 4 11 1525 Copyright c 1989 2003 Datalight Portions copyright c GPvNO 2004 compiled 04 13 2004 Going resident D WEBROOT gt A start ey iili Adam4500 Inc 6
37. shield as signal ground he higher the density of the shield the better especially for communication network Use double isolated cable for communication network Al AO e Both sides of shields should be connected to their frame while inside the device for EMI consideration e Don t strip off too long of plastic cover for soldering ADAM 4500 Series User s Manual C 11 Appendix C Grounding Reference C 2 2 System Shielding T rnm Never stripping too long of the plastic cable cover Cascade those shields together by Soldering i 8 Oo SM uem connect the shield to Frame Ground of DC Power Supply c oUm Figure C 11 System Shielding e Never stripping too much of the plastic cable cover This isimproper and can destroy the characteristics of the Shielded Twisted Pair cable Besides the bare wire shield easily conducts the noise e Cascade these shields together by soldering Please refer to following page for further detailed explanation e Connect the shield to Frame Ground of DC power supply to force the conducted noise to flow to the frame ground of the DC power supply The frame ground of the DC power supply should be connected to the system ground C 12 ADAM 4500 Series User s Manual Appendix C Grounding Characteristic of Cable CN wT This will destroy the twist rule Don t strip off too long of plastic cover for soldering or will Influance the char
38. switch into Initial mode CE ADAM 4500 Series Utility Yer 1 14 B File Help 4500DRV H E DemoRC c DEMORC EXE E DemoRC PRJ DemoRS c E DEMORS DSK DEMORS EXE E DemoRS PRJ E DemoTC c DEMOTC EXE E DemoTC PRJ DemoTS c E DEMOTS DSK I NE MOTS FXF launch Local System _ xe cem Alaco Hh CONF File Folder 2006 07 25 6 01 00 AM C Fil VVEBROOT File Folder 2006 07 25 6 01 00 AM Appl F AUTORUN BAT 1KB MS DOS B 2006 07 25 6 01 00 AM PRJ 7 4x8786 cOM 13KB MS DOS A 2006 07 25 6 01 00 4M C Fil CFGIO EXE 35KB Application 2006 07 25 6 01 00 AM DSK P DEMORS EXE 41KB Application 2006 07 25 7 01 00 AM Appl bEMoTs EXE 51KB Application 2006 07 25 6 01 00 4M PRJ sockerTP ExE 48KB Application 2006 07 25 6 01 00 amp M C Fil App PRJ CFil DSK ADAM 4500 Series la x 17 object s 230 0 KB 8 object s 185 9 KB 658 432 bytes free Directory of D N CONF DIR 07225 2006 6 11p WEBROOT lt DIR gt 07 25 2006 Pye bale AUTORUN BAT 128 07 25 2006 6 11p AX8796 COM 13 184 07 25 2006 6 11p CFGIO EXE 35 328 07 29 2006 6 11p SOCKETP EXE 48 896 07 25 2006 6 12p DEMOTS EXE 51 456 07 25 2006 6 19p DEHORS EXE 41 344 07 25 2006 qug b 8 file s 190 336 bytes 658 432 bytes free E Run DEMORS EXE ADAM 4500 Series Controller will Modbus RTU master and write DIO value to address 40001 f ADAM 4500 Series Utility Yer 1 14 b 81
39. 1 Bit 1 Bit 0 more 2 0 0 5 0 1 6 0 7 l 1 8 ADAM 4500 Series User s Manual A 3 Appendix A COM Port Register Structure BASE 4 Modem Control Register MCR bit 0 DTR bit 1 RTS BASE 5 Line Status Register LSR bit 0 Receiver data ready bit 1 Overrun error bit 2 Parity error bit 3 Framing error bit 4 Break interrupt bit 5 Transmitter holding register empty bit 6 Transmitter shift register empty bit 7 At least one parity error framing error or break indication in the FIFO BASE 6 Modem Status Register MSR bit 0 Delta CTS bit 1 Delta DSR bit 2 Trailing edge ring indicator bit 3 Delta received line signal detect bit 4 CTS bit 5 DSR bit 6 RI bit 7 Received line signal detect BASE 7 Temporary data register A 4 ADAM 4500 Series User s Manual Appendix B RS 485 Network Appendix B RS 485 EIA RS 485 is the industry s most widely used bidirectional balanced transmission line standard It is specifically developed for industrial multi drop systems that should be able to transmit and receive data at high rates or over long distances The specifications of the EIA RS 485 protocol are as follows Maximum line length per segment 1200 meters 4000 feet Throughput of 10M baud and beyond Differential transmission balanced lines with high resistance against noise Maximum 32 nodes per segment Bi directional master slave communication over
40. 27PM Type adam to run Run ADAM EXE fill ADAM 4500 Series Utility Yer 1 13 File Help Local System Application 44KB Application 45KB Application 50KB Application 28KB Application B3KB Application 1KB HTML Do 7 object s 257 5 KB E 15 xl ADAM 4500 Series Name Size Type modified ADAM EXE 30KB Application 2006 0741 4 6 02 00 4M FTPD EXE 45KB Application 2006 0714 6 00 00 4M HrTPD EXE S0KB Application 2006 0741 4 6 00 00 4M HrTPbEMO EXE 28KB Application 2006 07 4 4 6 01 00 AM 7HrTPFTPD EXE B3KB Application 2005 07 14 5 03 00 AM E WEBADAM HTM 1KB HTML Doc 2006 0744 6 02 00 AM 6 object s 214 1 KB 595 968 bytes free Sockets HITP RC Server v6 22 Revision 4 11 1525 Copyright c 1989 2003 Datalight Portions copyright c GPvNO 2004 compiled 04 13 2004 Going resident D WEBROOT gt adam Going TSR D WEBROOT gt d start aygo tli Adam4500 Inc ELE LE ADAM 4500 Series User s Manual 4 19 Chapter 4 Guidelines for Network Functions 6 Run IE on Host PC type the URL aas http 10 0 0 1 web adam htm Note 10 0 0 1 is the default IP of ADAM 4500 Series Controller and refer to SOCKET CFG under ADAM 4500 Series Utility Source Drive _D Default_files Conf to get the real IP address You can refer to SOCKET UPW for user name and password F http 10 0 0 1 index Microsoft Internet Explorer _ 2181 x Fi
41. 5 120 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library The function gethostbyaddr will always fail with errno WSANO_DATA All the file socket operations of BSD Sockets must be translated to the socket versions as used in Winsock e g closesocket instead of just close In Linux Unix a socket descriptor can be treated the same as a file descriptor not so for SAPI or Winsock For Winsock the WSAStartup and WSACleanup functions must be called make it conditional for portable code The socket set is defined differently for SAPI Winsock on the one hand and LINUX UNIX on the other Always use the FD macros for portable code Function Reference The following sections describe the individual functions of the SOCKETS API ADAM 4500 Series User s Manual 5 121 Chapter 5 Programming and Function Library accept Syntax SOCKET accept SOCKET so struct sockaddr psAdaress int p iAdadressLen Description Accepts a connection on a socket Parameters SO A descriptor identifying a socket which is listening for connections after a listen psAddress An optional pointer to a buffer which receives the socket address of the connecting peer piAdarLen An optional pointer to an integer which contains the length of the address psAdaress Return Value If no error occurs accept returns a value of type SOCKET which is a descriptor for the accepted packet Otherwise a va
42. 61 Chapter 5 Programming and Function Library SIO ModemHandup Syntax CHAR SIO ModemHandup UCHAH i ucPort Description oets the modem to hand up the telephone The command has the same effect as sending the ASCII command atho to the modem Parameter Description ucPort The Port number you want to use see remarks Return value If success return O If fail return a negative number as follows Illegal Setting b Remarks COM COMI 5 62 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library COM Port Communcation Example 2 Modem Refer to C Program Files Advantech ADAM 4500 Series Utility Source Example Basic_Function Ex4 C for this example include 4500drv h int get_modem_response char buf long i int index unsigned char C index 0 for i20 i 10000 i Get the receiving string from the COM1 port i SIO RecvBytes COM 1 UnBlock Mode 1 amp c gt 0 buf index c if index gt O0 amp amp c 22 w end of command buf index 0 adv_printf Response s buf return 1 return 0 void main char c int result code char buf 131 int index long i long retry SIO Modemlnitial COM1 ADAM 4500 Series User s Manual 5 63 Chapter 5 Programming and Function Library while 1 adv printf Main Menu n adv printf 0 Exit n adv printf 1 COM port setting M adv printf 2 Dia
43. ADAMModbusTCP Read for Modbus TCP The Modbus function 05 06 15 16 can be simply integrated into one write function as ADAMModbusRTU_ Write for Modbus RTU or ADAMModbusTCP Write for Modbus TCP However programmers should notice that those four functions are a little bit slower in performance than the original sixteen functions 5 72 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Modbus COM Init Syntax int Modbus COM Init int Port int iMode unsigned long iBaud int iParity int iFormat int iStopBits Description Initial a COM port for Modbus RTU connection Parameters Value Description Port COM1 Initial COM1 COM2 Initial COM2 COMS3 Initial COM3 COM4 Initial COM4 iMode Slave Modbus RTU slave mode Master Modbus RTU master mode iBaud 9600 etc The value of baud rate iparity NO PARITY No parity ODD PARITY Odd parity EVEN PARITY Even parity ONE PARITY Parity 1 ZERO PARITY Parity 0 iFormat DATA5 5 data bit DATA6 6 data bit DATA7 7 data bit DATA8 8 data bit iStopBits STOP1 One stop bit STOP2 Two stop bits Return value 0 No error occurs 1 COM_already_installed COM port has been installed before 2 Err Access COM Error occurs when try to access COM port ADAM 4500 Series User s Manual 5 73 Chapter 5 Programming and Function Library Example if Modbus_COM_Init COM2 Master unsigned long 9600 NO PARITY DATA8 STOP1 0 adv printf errorin return j ad
44. DGRAM andthe datagram is larger than the maximum supported by SOCKETS ECONNABORTED The virtual circuit was aborted due to timeout or other failure ECONNRESET The virtual circuit was reset by the remote side EADDRNOTAVAIL The specified address is not available from the local machine EAFNOSUPPORT Addresses in the specified family cannot be used with this socket EDESTADDRREQ A destination address is required ENETUNREACH The network can t be reached from this host at this time Remarks sendto is used on 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 If the data is too long to pass atomically through the underlying protocol the error EMSGSIZE is returned and no data is transmitted Note that the successful completion of a sendto does not indicate that the data was successfully delivered sendto is normally used on a SOCK _DGRAM socket to send a datagram to a specific peer socket identified by the psTo parameter On a SOCK STREAM socket the psTo and iTolen 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 socket h together with the intended port number It is generally inadvisable for a broadcast datag
45. Functions Chapter 4 Guidelines for Network Functions The network features of ADAM 4500 Series Controller are very rich In order to shorten the learning time about versatile network features the network functions will be present by step by step demonstration in this chapter The detail information oof related functions utilities and applications are shown on later chapters The sample programs can also be found after ADAM 4500 Series Controller utility on ADAM CD is installed Before you start to test the network functions you have to configure two files as following SOCKET CFG Text file contains related configuration command SOCKET UPW Text file contains user name and password SOCKETS Configuration Files SOCKET CFG HOSTS SOCKETS use two files in the DACFG directory default or any other directory specified by the SOCKETS environment variable These files are SOCKET CFG the default start up file and HOSTS the host names file If not found SOCKETS uses the default SOCKET CFG in the DACFG directory SOCKET CFG is a text file containing configuration commands Empty lines and lines starting with are ignored Commands are used to specify protocol parameters like the IP address of the stack interface parameters like Packet Driver or Asyncronous Serial lines routes and various other parameters Here is a simple example IP address demo Set the IP address of this host to 192 6 1 1 Interface pdr ifO dix 1500 5 Us
46. Help Backup Image m Write Image Estimate time 6minutes Restore Image Iz object s o byte s Volume Serial Number is 3Dgs Directory of D N lt DIR gt s It needs at least 10 KB free space on Adam 4500 lt DIR gt AJ D drive and be sure the Adam 4500 is in initial AUTORUN BAT 128 rg e to continue AX8796 COM Sse CFGIO EXE 35232A SOCKETP EXE 48 896 6 file s 37 664 bytes 754 688 bytes free start S YW 3 i adamasoo S ww 8 21PM 6 Select where you want to save the image file and type the image file name Then click the Save button FII ADAM 4500 Series Utility Ver 1 13 le x File Help Local System ADAM 4500 Series amp a xm e ga cow z My Computer hd i Name Sie Type Modified Name Size Type Modified Se UNO 3072 3074 w Removable Disk savaia 2 xl Removable Disk Save in Qtm rl e ft Ek EJ ss ADV SRAMDRV e Control Panel Ce Shared Documents E Mv Documents 2006 0649 7 01 00 AM 2006 0649 7 01 00 AM 2006 0649 8 00 00 AM 2006 0649 7 01 00 AM 2006 0649 7 01 00 AM 2006 0649 7 01 00 AM File name 7 objects 0 byte s Save as type Volume Serial N Directory of D N CONF DIR 06 19 2006 sip WEBROOT lt DIR gt 06 19 2006 ip AUTORUN BAT 128 06 19 2006 8 08p AX8796 COM 13 312 06 19 2006 up CFGIO EXE
47. Image 4 Estimate time 6minutes Restore Image Please wait system now is restoring your backup image i 7 object s lo byte s 754 176 bytes free start ey iii Adam4500 S WI WI 8 43PM ADAM 4500 Series User s Manual 3 29 Chapter 3 Program Download 7 Click the OK button to finish the restore process Reboot the ADAM 4500 Series Controller STI ADAM 4500 Series Utility Ver 1 13 File Help Local System 4DAM 4500 Series Alafo z Se LINO 3072 3074 s Removable Disk 123 File Folder 2006 0649 8 02 00 AM EE File Folder 2006 0649 7 01 00 4M s Removable Disk F is x File Folder 2006064 9 7 01 00 AM S ADV SRAMDRY F AA Imaga Worker 1KB MS DOSB 2006 06 19 8 00 00 AM gt Control Panel ate 7 me Hel 13KB MS DOS 4 2006 05 19 7 01 00 AM Shared Documents F ubi a sd Hep 35KB Application 2006 06 19 7 01 00 AM My Documents F em 48KB Application 2005 06 19 7 01 00 AM information 0x m Write Image ZI E Fully A eee A rite image successrully Estimate time amp min 1 J plaa e reboot Adam 4500 Message Please wait system n 7 object s lo byte s reis cosseffIng your backup image AX8796 COM CFGIO EXE EEEEBEEEEEEBEEEHEEEEEEEEEBHEEEEEEEEEEEEEU SOCKETP EXE 123 DIR 7 file s 754
48. Panel System Fol Shared Documents File Folder 3 1 2006 3 Mv Documents File Folder 5 15 2006 7 object s lo byte s 6 objects 95 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF DIR 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 1 02a CFGIO EXE 35 328 06 16 2006 1 02a SOCKEIP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free mE start S G Y ii adamasoo TL 3 11PM 4 Click the Backup Image button DI ADAM 4500 Series Utility Yer 1 13 l 8 xj File Help Local System ADAM 4500 Series m 2 gi cow Modified O CONF File Folder 20060649 6 02 00 AM WEBROOT File Folder 2006 0619 6 02 00 4M amp uTORUN BAT 1KB MS DOSB 2006 0619 6 02 00 AM 7 4x8786 coM 13KB MS DOS A 20060619 6 02 00 AM P CFGIO EXE 35KB Application 2006 0619 6 02 00 AM Se UNO 3072 3074 Local Disk s Removable Disk Removabl Removable Disk Removabl a ADV SRAMDRYV Removabl J Control Panel System Fol Shared Documents File Fold 3H nncao mAocn cve KB Application 20060649 6 03 00 AM My Documents File Fold DEE 2d KB Application 2006 0619 6 03 00 AM dam 4500 Image Worker Read Image Estimate time 10 minutes Write Image Z objects Dbytes Estimate time Bminutes Restore Image Directory
49. Re sprintf ptr Re HTTP 1 0 200 OK r nContent type text htmINNiNNi html h1 if strncmp buf DOValues 9 0 ptr_val buf 9 if p strchr ptr val amp NULL printf Please click Submit button n printf the DO val is Ox x n returnVal ptr val p SetDO EB50 ID AllChannels 0 returnVal ptr val p i ptr Re sprintf ptr Re lt P gt lt P gt lt A HREF WebAdam htm gt Back lt A gt lt html gt n HttpSendData psParams iHandle Re Htm Content ptr Re Re Htm Content return RET DONE j int returnVal char ptr name char ptr end int r Val buf idx char buf val 10 memset buf val 0 10 for buf_idx 0 buf idx 10 buf_idx ADAM 4500 Series User s Manual 4 23 Chapter 4 Guidelines for Network Functions if ptr name ptr end break buf val buf idx ptr name buf idx j sscanf buf val X amp r_Val return r_Val j WEBADAM htm lt html gt lt head gt lt head gt lt body gt lt b gt lt p gt lt p gt lt p gt lt p gt Please enter I O status in hexadecimal format and click Submit lt b gt form action Adam htm method post namez loginl table lt tr gt td align right gt lt input name DOValues type text size 30 maxlength 50 td lt tr gt Ir lt td gt lt input name submit type submit value Submit gt lt td gt lt tr gt lt table gt lt body gt l
50. Requirements Before you start to install the ADAM 4500 Series Controller make sure the system requirements as below 2 1 1 Host Computer Requirements IBM PC compatible computer with 486 CPU Pentium grade is recommended 2 Microsoft XP 2000 NT 98 95 or higher versions 3 DOS version 3 31 or higher 3 Borland C 3 0 for DOS 4 Atleast 32 MB RAM 5 20 MB of hard disk space available 6 VGA color monitor 7 2x or higher speed CD ROM 8 Mouse or other pointing devices 9 Atleast one standard RS 232 port e g COM1 COM2 10 One RS 485 card or RS 232 to RS 485 converter e g ADAM 4520 for system communication 11 Hub or Switch for Ethernet connection 2 2 ADAM 4500 Series User s Manual Chapter 2 Installation Guidelines 2 2 Hardware Installation 2 2 1 Jumper Settings This section tells you how to set the jumpers to configure your ADAM 4500 Series Controller It provides system default configuration and your options for each jumper There are four jumpers on the CPU card JP2 is for the reset mode setting JP5 is for battery backup RAM setting JP6 amp JP7 is for COM4 communication mode selection setting The following figure shows the location of the jumpers COMI RJ48 to DB9 R5 232 Ethernet port Figure 2 1 ADAM 4500 Series Jumper Definition ADAM 4500 Series User s Manual 2 3 Chapter 2 Installation Reset Mode Setting Jumper JP2 on the CPU card lets you configure the reset mode
51. RespByteCount The total bytes of query data Finally make a query Unlike server programming the mode is defined as Master instead of Slave Modbus COM JInit COM 1 Master unsigned long 9600 NO PARITY DATAG STOP1 ADAMModbusRTU Read COM SlavelD Read StartAdar Read EndAddr amp RespByteCount Resp From Server Now the RespByteCount should report this query has get 16 bytes data But where is the data The answer is quite simple as follows Resp From Server 0 gt 40001 Hi byte Resp From Server 1 gt 40001 Lo byte ADAM 4500 Series User s Manual 5 69 Chapter 5 Programming and Function Library Example Modbus TCP Server and Modbus TCP client Assume that we now need a Modbus TCP Server with valid address in the range of 40001 40008 Before starting to create a server we need to define some server information first such as the total numbers of connections and the timeout setting Zdefine TCP Port 502 502 is the standard port of modbus protocol Zdefine iTimeOut 3000 3000 msec for timeout setting Zdefine iConns 20 Only 20 client connections are avaliable And second we need to allocate a physical memory for address 40001 4008 int ModbusAddr Mem 8 X ModbusAddr Mem 0 25 40001 ModbusAddr_Mem 7 gt 40008 Finally we can create a server ADAMTCP_ModServer_Create TCP_Port iTimeOut iConns unsigned char ModbusAddr_Mem sizeof ModbusAddr_Mem while 1 put ADAMTCP ModServer Upd
52. SO LINGER is set i e the onoff field of the linger structure is non zero with a zero timeout interval inger 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 Any recv cal on the remote side of the circuit will fail with ECONNRESET 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 Note that if the socket is set to non blocking and SO LINGER is set to a non zero timeout the call to closesocket will fail with an error of EWOULDBLOCK If SO DONTLINGER is set on a stream socket i e the 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 SOCKETS may not release the socket and other resources for an arbitrary period which may affect applications which expect to use all available sockets See Also accept socket ioctlsocket setsockopt ADAM 4500 Series User s Manual 5 127 Chapter 5 Programming and Function Library connect Syntax int connect SOCKET so const struct sockaddr
53. TotalByte Byte count szData Force Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example HostData 0 Oxf0 If IADAMRTU ForceMultiCoils COM 1 0x02 0x64 0x08 0x01 HostData adv printf err code is d n Error Code adv printf fail send else adv printf Success ADAM 4500 Series User s Manual 5 77 Chapter 5 Programming and Function Library ADAMRTU ForceSingleCoil Syntax bool ADAMRTU ForceSingleCoil int iPort int i iAddr int i iCoillndex inti iData Description 05 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave address iCoillndex Coil address inti iData Force Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example I TADAMRTU ForceSingleCoil COM 1 0x02 0x65 0 adv_printf err code is d n Error_Code adv printf fail send else adv printf Success 5 78 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMRTU PresetMultiRegs Syntax bool ADAMRTU PresetMultiRegs int iPort int i iAddr int i iStartRHeg inti iTotalReg inti iTotalByte unsigned char i szDatal Description 10 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave address iStartReg Starting Address iTotalReg No of Registers Hi
54. When using the SOCK DGRAM service datagrams can be sent without first establishing a connection In fact UDP provides a connectionless service although the connection paradigm is used Blocking and Non blocking Operations The default behavior of socket functions is to block on an operation and only return when the operation has completed For example the connect function only returns after the connection has been performed or an error is encountered This behavior applies to most socket function calls such as recv and even send and especially on SOCK STREAM connections 5 116 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library In many if not most applications this behavior is unacceptable in the single threaded DOS environment and must be modified This modification can be accomplished by making all operations on a socket non blocking by calling ioctlsocket with the FIONBIO option If a non blocking operation is performed the function always returns immediately If the function could not complete without blocking an error is returned with errno containing EWOULDBLOCK This error should be regarded as a recoverable error and the operation should be retried preferably at some later time Out of band data TCP out of band or urgent data is not implemented Setting the MSG_OOB flag has no effect in recv recv rom send or sendto it wil simply be ignored The SO OOBINLINE opt
55. a socket pcBuf A buffer containing the data to be transmitted iLen The length of the data in pcBuf iFlags opecifies the way in which the call is made PsTo An optional pointer to the address of the target Socket ilTolen The size of the address in fo Return Value If no error occurs sendto returns the total number of characters sent Note that this may be less than the number indicated by en Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EACCES The requested address is a broadcast address but the appropriate flag was not set EFAULT The pcBuf or psTo parameters are not part of the user address space or the psTo argument is too small less than the sizeof a struct sockaddr ENETRESET The connection must be reset because SOCKETS dropped it ENOBUFS SOCKETS reports a buffer deadlock ENOTCONN The Socket IS not connected SOCK_STREAM only ENOTSOCK The descriptor is not a socket EOPNOTSUPP MSG OOB was specified but the socket IS ADAM 4500 Series User s Manual 5 163 Chapter 5 Programming and Function Library 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 EMSGSIZE The socket is of type SOCK
56. amp SO 4500 return O j 5 106 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library else i adv_printf Adam 5024 Status for tmp 0 tmp lt DataByteCount tmp adv_printf 02X HostData tmp j adv printf n j ADAM 4500 Series User s Manual 5 107 Chapter 5 Programming and Function Library ADAMTCP ReadinputStatus Syntax int ADAMTCP ReadlnputStatus SOCKET SO int WaitMilliSec int Slave Addr int Startlndex int TotalPoint int ByteCount char wData Description 02 HEX command Modbus TCP function code Parameters Desceription SO The socket connected to Modbus TCP server WaitMilliSec Set duration msec unit for the response from Modbus TCP server Slave_Addr Slave address StartIndex Starting address TotalPoint No of points ByteCount Byte count wData Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example This example demonstrates how to use ADAMTCP_ReadInputStatus to query remote Modbus TCP module such as ADAM 5000 TCP And here it queries ADAM 5051 inserted in Slot 1 on the ADAM 5000 TCP i ADAMTCP_ReadInputStatus amp SO_ 4500 50 0x01 0x11 0x10 amp DataByteCount HostData lt 0 perror ADAMTCP_ReadInputStatus n ADAMTCP_Discon
57. any reason This feature increases system reliability in industrial standalone and unmanned environments If you decide to use the watchdog timer you must write a function call to enable it When the watchdog timer is enabled it must be cleared by the application program at intervals of less than 1 6 seconds If it is not cleared at the required time intervals it will activate and reset the CPU or generate a NMI Non Maskable Interrupt You can use a function call in your application program to clear the watchdog timer At the end of your program you still need a function call to disable the watchdog timer 5 6 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 2 Category of Function Libraries ADAM 4500 Series Controller has 10 categories of function libraries as following Category A System Functions UTILITY LIB Category B I O Module Functions HIO LIB Category C Communication Functions A4 COMM LIB Category D MODBUS RTU Functions RTU LIB Category E MODBUS TCP Functions MBTCP LIB Category F Socket Functions SOCKET LIB Category G HTTP Functions CGI LIB LIB Note 1 These function libraries support Borland C 3 0 for DOS only Note 2 Please include all necessary ADAM 4500 Series function libraries in your project file 5 2 1 Category A System Functions UTILITY LIB adv printf ADAMdelay Get BoardlD Get NodelD GetRTCtime SetRTCtime LED
58. as a 213 message Shell to DOS for IFTP EXE Report the status of a transfer or active connections Return operating system information from the server Report or select the file transfer mode image binary or ASCII Username to logon Verbose mode reports more of the negotiations Chapter 6 Sockets Utility IFSTAT IFSTAT displays the status of the Interface and the version information for SOCKETS Syntax IFSTAT i v Options i show the Interface status V show the version information Example IFSTAT v X This will display the SOCKETS version information ADAM 4500 Series User s Manual 6 7 Chapter 6 Sockets Utility IPSTAT The IPSTAT utility returns statistics on IP and memory Use IPSTAT to check for error conditions and memory problems Syntax IPSTAT Example IPSTAT The following will be displayed The values may differ IP stats at 160F 04C8 Total Packets 2671 Smaller than minimum size 0 IP header length too small 0 Wrong IP version 0 Unsupported protocol 0 Memory available 9016 Memory allocation failures 0 Memory free errors 0 Minimum stack observed 886 6 8 ADAM 4500 Series User s Manual Chapter 6 Sockets Utility MAKEMAIL MAKEMAIL packages the body text and any attachments for delivery using the SENDMAIL application Syntax MAKEMAIL tToAddress fFromAddress sSubject bBodyTextFile oOutputFileaAttachment Options ToAddress The e mail address of the recipient s of this ma
59. by HTTPD a DWORD User ID to be used in callbacks and whether requests should be allowed to overlap i e a new request can be received while still servicing a previous request or requests ADAM 4500 Series User s Manual 5 195 Chapter 5 Programming and Function Library The Callback function will be called when a request for the registered path is received and as many times afterwards as is necessary to complete the request It is called with a parameter structure specifying the reason for the request the User ID an HTTPD handle and values specific to the reason for the callback e g a pointer to the command line on the initial callback Other reasons for calling the Callback function are to notify of new received data connection closure by the peer readiness to accept more data and connection errors The callback must return a value to indicate that it is still busy handling the request has completed the request or wants to abort the request with an error The HTTPD handle will be constant and unique from the first callback to the completion of the request While in the Callback function data can be read from the peer or sent to the peer and a file can be submitted to be sent to the peer Note Extensions are responsible for sending all HTTP header fields to clients The following extensions have been developed for functional and demonstrational purposes SSI Interface If you want to display the current date and time or
60. byte rearrangement See Also inet ntoa ADAM 4500 Series User s Manual 5 141 Chapter 5 Programming and Function Library inet ntoa Syntax char inet ntoa struct in addr s n Description Converts a network address into a string in dotted format Parameters Description sin A structure which represents an Internet host address Return Value 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 SOCKETS call is made Remarks This function takes an Internet address structure specified by the s n parameter It returns an ASCII string representing the address in notation as a b c d Note that the string returned by inet ntoa resides in memory which is allocated by SOCKETS 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 but no longer See Also inet_addr 5 142 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ioctisocket Syntax int ioctlsocket SOCKET so long Cmd u long pulArgp Description Controls the mode of a socket Parameters Description SO A descriptor identifying a socket ICmdad The command to perform on the socket so pulArgp A pointer to a parameter for Cmd Return Value Upon successfu
61. cgji bin getpage exe you should register cgibin getpage exe pfCallback Address of callback function Return values when returning from callback HET OK not done give me more upcalls RET DONE done no more upcalls please RET ERR done error psHttpParams Far pointer to HTTP parameter block psHttpParams iReason Reason for callback RH NEWHREQ New HTTP request pszCommandLine points to the command line passed in the URL The number contained in iValue specifies the HTTP operation RQ GET for GET and RQ POST for POST 5 200 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library OUTDATA Can send output data iValue contains count RH ENDDATA Peer closed connection i e end of input data RH CLOSED Connection closed ADAM 4500 Series User s Manual 5 201 Chapter 5 Programming and Function Library psHttpParams gt iHandle HTTPD handle used in subsequent API calls for this request The user should not modify it See HTAPIC H for the other definitions iflags F_OVERLAP Overlapped request 1 non overlapped request 0 All other bits are reserved dwUserlD Value passed to HttoRegister this value is for use by the extension HTTPD does not modify it Return value 0 OK lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF_REGISTER 0 DS SI szPath ES DI pfCallback BX iFlags CX DX dwUserlD Low level return parameters Return code in AX No
62. d cdwEBHOOI SER Volume in drive D has no Labsl Volume Serial Number 19 J64b 10F Directory of D W ENROOT DIE CE i SDR 7 04 7006 1 z7n EE PGE EEUU 3 73 7 04 7006 LER EKZ 4 7006 LU 04a SH bytes bytes Frov Ir WEBROOT sa 5 L3 I Adan rsuo Wi 10 05 5M under ADAM 4500 Series User s Manual 4 9 Chapter 4 Guidelines for Network Functions 2 Using HTTPDEMO PRu to Build HTTPDEMO EXE under ADAM 4500 Series Utility Source Example httpEx and download HTTPDEMO EXE onto drive D under Webroot directory fill ADAM 4500 Series Utility Yer 1 13 I 81 xj File Help Local System ADAM 4500 Series xs ems ejum cow z WEBROOT Nam Size Type Modified FTPD EXE 45KB Application 20060714 6 00 00 AM HrTPD EXE 50KB Application 200690714 6 00 00 AM E HTTPFTPD EXE 63KB Application 2006 07 14 5 03 00 AM Application 44KB Application 45KB Application 63KB Application 1KB HTML Do n 7 object s 257 5 KB object s 156 4 KB 655 360 bytes Free Volume in drive D has no label Volume Serial Number is 1437 18F5 Directory of D WEBROOT lt DIR gt 07 14 2006 5 31ip M DIR 07 14 2006 5 31p HITPFTPD EXE 64 256 07 14 2006 5 32p HTTPD EXE 50 432 07 14 2006 6 06p FTPD EXE 45 440 07 14 2006 6 08p 5 file s 160 128 bytes 655 360 bytes free d start S Wy 3 iii adamasoo Sw 6 11PM fil ADAM 4500 Series Utility Yer 1 13
63. define a connection The API uses a socket handle sometimes referred to as simply a socket The socket handle is required by most function calls in order to access a connection The socket handle used is the same as a normal socket as used in CAPI A socket handle is obtained by calling the socket function A socket handle can only be used for a single connection When no longer required such as when a connection has been closed the socket handle must be released by calling closesocket Socket handles are positive numbers greater than 63 Types of Service SOCKETS can be used with one of two service types SOCK STREAM using TCP SOCK DGRAM using UDP A stream connection provides for the bi directional reliable sequenced and unduplicated flow of data without record boundaries No broadcast facilities can be used with a stream connection A datagram connection supports bi directional flow of data that is not guaranteed to be sequenced reliable or unduplicated hat is a process receiving messages on a datagram ocke ma inc 5 114 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library possibly in an order different from the order in which it was sent An important characteristic of a datagram connection is that record boundaries in data are preserved ADAM 4500 Series User s Manual 5 115 Chapter 5 Programming and Function Library Datagram connections closely model the facilities found i
64. digital input output on n 18 x 44 4500 Series vv Nam Size Type Modified Se UNO 3072 3074 Local Disk ss Removable Disk Removabl s Removable Disk Removabl S ADV SRAMDRY Removabl J Control Panel System Fol 3 Shared Documents File Folder 3 1 2006 3 My Documents File Folder 6 16 2006 File Folder 2006 0616 1 00 00 AM C WwEBROOT File Folder 2006 0616 1 00 00 AM fs AUTORUN BAT 1KB MS DOSB 2006 0616 1 00 00 AM f 4x8796 cOM 13KB MS DOS A 2006 0646 1 00 00 AM f CFGIO EXE 35KB Application 2006 0646 1 00 00 AM sockETP EXE 48KB Application 2006 0616 1 00 00 AM object s 0 byte s le object s 95 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF lt DIR gt 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 1 02a CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free start S O Wy ii adamasoo TL 3 11PM ADAM 4500 Series User s Manual 3 7 Chapter 3 Program Download 5 Check if there is enough space for download this application to disk on ADAM 4500 Series Controller Refer to the status bar If the space is greater than 40KB click the Yes button to continue fll ADAM 4500 Series Utility Yer 1 13 Hc J 18 x File Help Local System AD
65. directory ADAM 400 Series Liity Yer 1 13 Feii ialo sam 7 MAIL TXT MOTT 2000 Id WB Tex Docu 1 Maie c XB C Souce SETAE 14312 MARE MAIL EXE JOEB Appbiaben AAA 203 00 AM zi AMAL OSE 3B DS Fig CEO 144 7 END MAIL EXE HDE Appian DGA 203 00 8M TEA Apiso ODESUTZAIS 44 jaja Pr TED AAE SOMATA tl 5 bet ay Ac EB objatia 51 0 rA 206 byes Free C stransimr B D SNATLS SEWDHATL KXK 7 ttTranetoarriog Fi thot ACK for wots d cal A TL ir Yolume in drive D ham mo Label foluas Gerial Humber im 2 amp 5E 12D Directory of D EAIL iDIR OF7 10 7006 2 DIRS 7 1 700i JO 120 Df 1H 2UU0f Jip HAKEHAIL E 2W 544 UT 1H 7UUb J3A mp SENDHAIL EXE 24 44H DT 1H 2006 2 Pip filets 513 1270 bytes 541 696 belies ren i_ Chapter 4 Guidelines for Network Functions T Put switch into Normal mode and then reboot Type cd mail to enter Mail directory Type amail to run AMAIL EXE This executive will execute MAKEMAIL EXE to build e mail content Type the DO output value to trigger the action to send e mail ADAM 400 Sarkis LMG Wer 1 03 MOTITI WERE Acok wer Pu 8 elis 33 EB obiectis Sp Ee en ree i ai Light GSecketea HAKENAIL v 27 Revisie it 1709 7007 Tata n 8 The executive will execute SENDMAIL EXE to send the e mail content created by previous step 4 28 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions ADAM 4 40K Seri
66. does not allow anonymous logins or the e mail address was not accepted FTP server 10 0 0 1 User name ftp1 Password ecce After you log on you can add this server to your Favorites and return to it easily NS FTP does not encrypt or encode passwords or data before sending them to the server To protect the security of your passwords and data use Web Folders WebDAV instead Learn more about using Web Folders m Log on anonymously Save password cm Connecting to 10 0 0 1 Unknown Zone A start S WY iii Adam4500 amp ftp 10 0 0 1 Micro Lo LEAR ONEA TALEE W 9 44 AM 5 Check the files under Webroot directory are correctly 1 ftp 10 0 0 1 Microsoft Internet Explorer File Edit View Favorites Tools Help Qe E 5 re Search Folders la L x ep Eii Address ftp 10 0 0 1 FTPD EXE HTTPFTPD EXE TMP1 lUser Ftp1 Internet A start WE Wii Adam4500 amp ftp 10 0 0 1 Micro Lo USBI URNS Oates mi 9 45 AM 4 8 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 2 HTTP Server lt lt Example 1 gt gt Example program HTTPDEMO EXE without CGI function Source file HTTPDEMO C under ADAM 4500 Series Utility Source Example nttpEx directory refer to Page 4 14 Utility HTTPD EXE System configuration Running HTTP server on ADAM 4500 Series Controller Using Web Browser to connect
67. following folder To install to this folder click Next To install to a different folder click Browse and select another folder Y ou can choose not to install ADAM 4500 Series Utility by clicking Cancel to exit Setup Destination Folder C WADAM 4500 Series Utility Browse lt Back Cancel 5 Set name for Program Folder and click the Next button a ial x Select Program Folder Setup will add program icons to the Program Folder listed below You may type a new folder name or select one from the existing Folders list Click Next to continue Program Folders Adam 4500 Series Utility Existing Folders Administrative Tools Advantech Powerview Startup lt Back Cancel 3 4 ADAM 4500 Series User s Manual Chapter 3 Program Download 6 Click the Finish button to complete the installation 7 After the ADAM 4500 Series Utility has been installed you willfind three directories under C Program Files Advantech ADAM 4500 Series Utility directory as following ADAM 300 Senes Utility Config Configuration tool SIMT445 001 EXE Program ADAM 4500 series utility Source Image function libraries and examples Drive D Dive D files for ADAM 4501 Default files Needed by ADAM 4501 Extension files Option files for ADAM 4501 Example Example programs Basic Function Basic function examples DemoModhus Simple examples of Modbus ETU and Modbus TCT httpEx Example
68. for all the systems and equipments ADAM 4500 Series User s Manual C 5 Appendix C Grounding Reference Normal Mode amp Common Mode Neutral Live Hot Ground Ground pin Is longer than athers for first contact to power systam and noise bypass Neutralpin Is broader thanLivepin for reduce contacted Impedance Figure C 4 Normal mode and Common mode e Ground pin is longer than others for first contact to power system and noise bypass Neutral pin is broader than Live pin for reducing contact impedance C 6 ADAM 4500 Series User s Manual Appendix C Grounding C 1 4 Wire impedance What s the purpose of High Voltage Transmission pu High Voltage Transmission Generator End User Raise Voltage Down Voltage Referring to OHM rule above diagram shows that how to reduce the power loss on cable Figure C 5 The purpose of high voltage transmission e What s the purpose of high voltage transmission We have all seen high voltage transmission towers The power plant raises the voltage while generating the power then a local power station steps down the voltage What is the purpose of high voltage transmission wires According to the energy formula P V I the current is reduced when the voltage is raised As you know each cable has impedance because of the metal it is made of Referring to Ohm s Law V R this decreased current means lower power losses in the wire So
69. init LED OFF LED ON EraseSector ProgramByte ProgramSector read mem Get SysMem oet SysMem Get NVRAM Size Set NVRAM Size write backup ram read backup ram Timer Init Timer Heset Timer Set Helease All tmArriveCnt ADAM 4500 Series User s Manual 5 7 Chapter 5 Programming and Function Library WDT clear WDT disable WDT enable display inti display digit BatteryStatus Ver 5 2 2 Category B I O Module Functions HIO LIB InitDIFilter GetDIO SetDIO Ver HIOLib 5 2 3 Category C Communication Functions A4 COMM LIB SIO Open SIO Close SIO SetState SIO RecvBytes SIO SendBytes SIO GetAvaiRHecvBytes SIO GetAvaiSendBuf SIO PurgeBuf SIO MakeCheckSum SIO MakeCHRC16 SIO Carrier SIO ClearBreak SIO SetBreak SIO GetLineStatus SIO SetLineParams SIO GetModemsStatus SIO LowerRaise RIS DTR SIO Modeminitial SIO ModemAutoanswer SIO ModemCommand SIO ModemCommand State SIO Modembial SIO ModemHandup Ver COMLib 5 8 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 2 4 Category D MODBUS RTU Functions RTU LIB Modbus COM Init Modbus COM Release Error Code ADAMRTU_ ForceMultiCoils ADAMRTU ForceSingleCoil ADAMRTU PresetMultiRegs ADAMRTU PresetSingleReg ADAMRTU_ ReadCoilStatus ADAMRTU_ReadHoldingRegs ADAMRTU_ReadinputRegs ADAMRTU ReadinputStatus ADAMHRTU ModServer Create Ve
70. message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example HostData 1 0x33 force channel status to 0x3333 If ADAMTCP ForceMultiCoils amp SO 4500 50 0x01 0x21 0x10 0x02 HostData lt 0 perror ADAMTCP_ForceMultiCoils n ADAMTCP_Disconnect amp SO_ 4500 return O 5 94 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMTCP ForceSingleCoil Syntax int ADAMTCP_ForceSingleCoil SOCKET int SO int WaitMilliSec Slave Addr int Coillndex int Data Description 05 HEX command of Modbus TCP function code Parameters SO WaitMillisec from Slave_Addr Coillndex Data Return value TRUE 0 Example Desceription The socket connected to Modbus TCP server Set duration msec unit for the response Modbus TCP server Slave address Coil address Force Data No error occurs Time out error when receive modbus query message from Modbus TCP server Error occurs when send modbus query message Modbus TCP server Error occurs when receive modbus query message from Modbus TCP server if ADAMTCP ForceSingleCoil amp SO 4500 50 0x01 0x25 1 lt 0 perror ADAMTCP ForceSingleCoil n ADAMTCP Disconnect amp SO 4500 return 0 j ADAM 4500 Series User s Manual 5 95 Chapter 5 Programming and Function Library ADAMTCP PresetMultiRegs Syntax int ADAMTCP PresetMultiRegs SOCKET SO int
71. note brings you some concepts about field grounding and shielding These topics will be illustrated in the following pages 1 Grounding 1 1 The Earth for reference 1 2 The Frame Ground and Grounding Bar 1 3 Normal Mode and Common Mode 1 4 Wire impedance 1 5 Single Point Grounding 2 Shielding 2 1 Cable Shield 2 2 oystem Shielding 3 Noise Reduction Techniques 4 Check Point List C 2 ADAM 4500 Series User s Manual Appendix C Grounding C 1 Grounding C 1 1 The Earth for reference Why we think the _ EARTH as Enn As you know that tha EARTH can t be conductive indeed But those parallel resistors make the EARTH as a single polnt and just for reference Figure C 1 Think the EARTH as GROUND As you know the EARTH cannot be conductive However all buildings lie on or in the EARTH Steel concrete and associated cables such as lighting arresters and power system were connected to EARTH Think of them as resistors All of those infinite parallel resistors make the EARTH as a single reference point ADAM 4500 Series User s Manual C 3 Appendix C Grounding Reference C 1 2 The Frame Ground and Grounding Bar Single Phase Three Line Neutral is the physical cable from Generator Ground is the local physical cable that connected to Ground Bar Figure C 2 Grounding Bar Grounding is one of the most important issues for our system Just like Frame Ground of the com
72. occurs when connects to Modbus TCP server Example IffADAMTCP Connect amp SO 4500 ServerlP Server_Port lt 0 perror ADAMTCP Connect n ADAMTCP Disconnect amp SO 4500 return O j 5 92 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMTCP Disconnect Syntax bool ADAMTCP Disconnect SOCKET SO Description Disconnect to Modbus TCP Server Parameters SO A descriptor identifying the connected socket to Modbus TCP server Return value TRUE No error occurs FALSE There is error occurs Example IffADAMTCP Connect amp SO 4500 ServerlP Server_Port lt 0 perror ADAMTCP_Connect n ADAMTCP_Disconnect amp SO_ 4500 return 0 ADAM 4500 Series User s Manual 5 93 Chapter 5 Programming and Function Library ADAMTCP ForceMultiCoils Syntax int ADAMTCP ForceMultiCoils GOCKET SO int WaitMilliSec int Slave Addr int Coillndex int TotalPoint int TotalByte unsigned char szData Description OF HEX command of Modbus TCP function code Parameters Desceription SO The socket connected to Modbus TCP server WaitMilliSec Set duration msec unit for the response from Modbus TCP server Slave_Addr Slave address Coillndex Coil address TotalPoint Quantity of coils TotalByte Byte count szData Force Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query
73. of D N 101 8 KB 700 928 bytes free CONF DIR 06 19 2006 6 29p WEBROOT DIR 06 19 2006 6 29p AUTORUN BAT 128 06 19 2006 6 29p AX8796 COM 13 312 06 19 2006 6 29p CFGIO EXE 35 328 06 19 2006 6 29p SOCKETP EXE 48 896 06 19 2006 6 30p REID EXE 6 528 06 19 2006 6 3lp 7 file s 104 192 bytes 700 928 bytes free start S Y 3 ii adamasoo MLM S 6 48PM 3 24 ADAM 4500 Series User s Manual Chapter 3 Program Download 5 There will be warning dialog window showing Check if there is 10KB free space on drive D of ADAM 4500 Series Controller by the status bar at the bottom of right window If the size is greater than 10KB click the Yes button to continue HIT ADAM 4500 Series Utility Ver 1 13 81 xj File Help Local System ADAM 4500 Series xm Alafo z se LINO 3072 3074 Local Disk D CONF File Folder 2005 0649 7 01 00 AM w Removable Disk Removabl WEBROOT File Folder 2006 0649 7 01 00 AM a Removable Disk Removabl S AUTORUN BAT 1KB MS DOS B 2005 06 19 8 00 00 AM a ADV SRAMDRV Removab ESI AVATAR COM 17WB MS DOS A 2006 0619 7 01 00 AM I Control Panel System Fi Advantech Image Worl x B Application 2006 0649 7 01 00 AM Shared Documents File Folde amp dam 4500 Image Worker B Application 2006 0649 7 01 00 AM My Documents File Folde Read Image Estimate time 10 minutes
74. 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 whet her 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 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 _onoff intl linger j To enable SO LINGER the application should set onoff to a non zero value set inger to O or the desired timeout in seconds and call setsockopt To enable SO DONTLINGER i e disable SO LINGER onoff should be set to zero and setsockopt
75. printf Content type text html n n lt html gt n lt h1 gt nThis page has been visited d times n lt h1 gt n number printf lt P gt lt P gt lt A HREF index htm gt Back lt A gt lt html gt n 5 192 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Forms programming can be performed using either the GET or POST methods When GET is used form data is copied to the command line and is limited to 128 characters including the URL part When the POST method is used the command line is also built In addition form data are available from STDIN and is limited by disk space only See the forms programming example consisting of FORM HTM FORM EXE and FORM C for examples of using both the GET and POST methods So that you may fully understand CGI programming this detailed explanation of the server operation is provided Whenever HTTPD receives a URL containing cgi bin it interprets the rest of the URL as a DOS program to spawn and run to completion The full path parsed from the URL is used implying that the program should be in physical directory called cgi bin or asubdirectory thereof E g program exe should be in S HTTP_DIR cgi bin if the request is GET cgibin program exe While this CGI program is executing the server can accept new server connections but will not respond to them before the CGI program terminates The CGI program can be any DOS program tha
76. psAdaress int iAddressLen Description Establishes a connection to a peer Parameters Description SO A descriptor identifying an unconnected socket psAddress The socket address of the peer to which the socket is to be connected iAddressLen The length of psAdaress Return Value If no error occurs connect returns 0 Otherwise it returns SOCKET ERROR and a specific error code is returned in errno 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 SOCKET ERROR and errno indicates an error code of EWOULDBLOCK then your application can either 1 Use select to determine the completion of the connection request by checking if the socket is writeable or 2 Use recv until either no error or an error of EWOULDBLOCK is returned Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EADDRINUSE The specified address is already in use EADDRNOTAVAIL The specified address is not available from the local machine EAFNOSUPPORT Addresses in the specified family cannot be used with this socket ECONNREFUSED The attempt to connect was forcefully 5 128 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library rejected ADAM 4500 Series User s Manual 5 129 Chapter 5 Programming and Function Library EDESTADDREQ A destination address is required EFAULT The AddressLen
77. record of requested type Remarks getservbyname returns a pointer to the following structure which contains the name s and service number which correspond to the given service pszName struct servent char s name char s aliases shorts port char s proto j 5 188 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library The members of this structure are Element Usage s name Official name of the service s aliases A NULL terminated array of alternate names S port The port number at which the be contacted Port numbers are returned in network byte order S proto The name of the protocol to use when contacting the service The pointer which is returned points to a structure which is allocated by the SOCKETS library The application must never attempt to modify this structure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls See Also getservbyport ADAM 4500 Series User s Manual 5 189 Chapter 5 Programming and Function Library getservbyport Syntax struct servent getservbyport int port const char proto Description Gets service information corresponding to a port and protocol Parameters Description Port The port for a service in network byte order Proto An optional pointer to a protocol name is NULL getservbyport returnsthe first service entry for which the port matc
78. result parameter that is filled in with the socket address of the connecting peer The p AddressLen is a value result parameter it should initially contain the amount of space pointed to by psAddress on return it will contain the actual length in bytes of the socket address returned This cal is used with the connectionbased SOCK STREAM socket type If osAddress and or p iAddressLen are equal to NULL then no information about the remote peer socket address of the accepted socket is returned See Also bind connect listen select socket ADAM 4500 Series User s Manual 5 123 Chapter 5 Programming and Function Library bind Syntax int bind SOCKET so const struct sockaddr psAdaress int iAddressLen Description Associates a local socket address with a socket Parameters SO A descriptor identifying an unbound socket psAddress The socket address to assign to the socket The sockaddr structure is defined as follows struct sockaddr u_short sa_family char sa data 14 t iAddressLen The length of the name psAdaress Return Value If no error occurs bind returns O Otherwise it returns SOCKET ERROR and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EADDRINUSE The specified address is already in use See the SO REUSEADDR socket option under setsockopt EFAULT The jAddressLen argument is too small less than
79. so psSet Removes the descriptor so from set FD ISSET so pSset Nonzero if so is a member of the set zero otherwise FD_SET so psSet A Adds descriptor so to set FD ZERO psSet Initializes the set to the NULL set The parameter psT meout controls how long the select may take to comp lete If psT meout is a null pointer select will block indefinitely until at least one descriptor meets the specified criteria Otherwise psTtimeout points to a struct timeval which specifies the maximum time that select X should wait before returning If the timeval is initialized to 0 O select will return immediately this is used to poll the state of the selected sockets See Also accept connect recv recvfrom send ADAM 4500 Series User s Manual 5 159 Chapter 5 Programming and Function Library send Syntax int send SOCKET so const char pcBuf int iLen int iFlags Description Sends data on a connected socket Parameters Description SO A descriptor identifying a connected socket pcBuf A buffer containing the data to be transmitted iLen The length of the data in pcBuf iFlags opecifies the way in which the call is made Return Value If no error occurs send returns the total number of characters sent Note that this may be less than the number indicated by Jen Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN
80. to stdout A single header line followed by an empty line containing Contenttype content type may be pre pended to the data This line will be used to set the content type of the data being sent back If such a header is not found the content type will be set to text plain Overview of the Extention API The SOCKETS HTTP servers HTTPD HTTPFTPD provide a facility to call functions in other modules which may be TSR or transient programs These functions are referred to as HITPD extensions HTTPD or HTTPFTPD must be loaded as a TSR using the r switch It provides an API via software Interrupt 63Hex The API can be located by searching for a signature containing SOCkHTTPD starting 10 bytes before the interrupt entry point and terminated by a 0 byte A CGI adapter is provided that simplifies the communication with the server It is located in a file called CGIADAP C The adapter finds the signature and provides a C interface lt also intercepts the callback function and performs a stack and context switch which makes implementing an extension much easier An HTTPD extension registers interest in a specific URL by calling the HttpRegister API specifying a path Note that this path has nothing to do with an actual file path on the server and will override any real path that may be used for serving static pages The HttpRegister function also specifies a Callback function to be called when the actual request is received
81. to the HTTP server on Host PC T Download HITPD EXE under MADAM 4500 Series Utility Source Drive DExtension files onto drive D Webroot directory Put switch into Initial mode ADAM 4500 Series Utility Ver 1 13 ATA AREE Iris gel 3 2 e m a Ef ONT TE ENSE DIEN IEA opc A FT fet ExE ax ie mm e F 145 4008 Appen 2 S31 1er reo EXE EH Appia PG 2 Ono aM EEN Appke ston OD Apple sto EFD Appin Ii m AR HED Appia i TKH HTML Do 4 objects 283 3 m Z obiectis 152 1 KB TO O40 bybes res 1 EXE 40 096 OF 04 2006 gigTa amp File u 7 664 bytes 706 040 bytes Eron d cad swEImRULCGT dir Volume in drive D has no label Volume Serial Humber is 3646 L0F0 Directory of f WEDROOT s 07 04 2006 J 27a DIR 07 04 2006 g z7a HTITIPFIPD EXE 64 2756 07 04 2006 8 7Ha FIFO EXE 45 440 07 04 2006 g d7A 4 Failw u 109 696 bytes 706 046 bytes rec n E Esan 2 C am Adamso 10005 AM ADAM 50 0 Series Utility Ver 1 13 xj Lese ad f yea AAA SS Seis ajoja ns fief ET ee ees fm maf Ez Program Ficidae h ADAE Der Lb Han Sue Type i I ERA Appleton ereo be 44H Appicsion OEC UOA UO AM 4408 Appice 2 are Bok SH Apxokcahon SOROS TOL OT A IL EN Appian N E eeo GD Apphnahen Suu S000 AM L1 DED Appian H i SD Apaan 2 I1 EFD Appicaon N I amp i IED HTML Din l x 7 obiectis 287 3 yn 3 obiectis 156 4 KIA 360 bytes Free
82. version of library is s n library ver j Remarks None ADAM 4500 Series User s Manual 5 67 Chapter 5 Programming and Function Library 5 3 4 MODBUS RTU Functions RTU LIB Before using Modbus Functions please read the Modbus Quick Start below to understand how to use Modbus libraries ick Start of MBTCP Lib and MBRTU Li Only two steps are needed to create a server or make a client query How to Create a Modbus TCP RTU Server Modbus RTU Server Step 1 Use Modbus COM Init function to initialize a COM port for Modbus RTU Server Step 2 Use ADAMRTU_ ModServer Create to create Modbus RTU Server Modbus TCP Server Step 1 Use ADAMTCP_ModServer_Create function to create a Modbus TCP server Step 2 Call ADAMTCP_ModServer_Update function periodically to check if there is any client message and keep the server alive How to Create a Modbus TCP RTU Client Modbus RTU Client Step 1 Use Modbus COM _Init function to initialize a COM port for Modbus RTU Client Step 2 Use ADAMModbusRTU_Read to query data from server or use ADAMModbusRTU_Write to write data to server Modbus TCP Client Step 1 Use ADAMTCP_Connect to make a connection to server Step 2 Use ADAMModbusTCP_Read to query data from server or use ADAMModbusTCP_Write to write data to server Example Modbus RTU Server and Modbus RTU client Assume that we now need a Modbus RTU Server w
83. web pages perform specialized tasks etc 4 A Server Side Includes SSI interface is provided using the CGI interface enabling a user to create web pages using HTML templates with variable names substituted in time with specific values 5 Ability to run as a background process 6 Flexibility to control physical parameters such as memory usage and number of connections Server The HTTP server is used to send static web pages existing as files on the server or dynamically generated web pages to a remote client browser Dynamic pages can be generated in two ways 1 Extension CGI By calling an external CGI handler the server provides an API to external handlers A Server Side Includes SSI interface is provided as well which makes it very easy to create powerful interactive web pages 2 Spawning CGI By spawning programs with a relatively short execution time to generate the pages through a mechanism similar to CGI the basic mechanism used by CGI is that arbitrary programs can be spawned from the web server with input as received from the remote browser and output that can be sent to the browser The Remote Console Server accepts input from a remote client that is fed to the keyboard buffer for use by an arbitrary program using it It also monitors the screen display buffer area and sends screen information to the remote client 7 2 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Application The SOCKETS
84. 0 01 01 12 00 00 PM P USERVER EXE 34KB Application 2006 07 2 P TCLIENT EXE 35KB Application 1980 01 01 12 00 00 PM P UCLIENT EXE 35KB Application 1980 01 01 12 00 00 PM gt la object s 159 4 KB 10 object s 233 0 KB 609 280 bytes free if Packet driver at Ox60 using h w int 7 Unknown host 0 Hostname 10 0 0 3 i 10 0 0 3 Net mask 255 0 0 0 ve 7 D gt uclient 10 0 0 2 sent 20 bytes to 10 0 0 2 got Ack packet ACK from 10 0 0 2 4 74 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions UDP SERVER C include lt stdio h gt include lt stdlib h gt ifdef MSC_VER include lt malloc h gt else include lt mem h gt endif include lt string h gt include lt conio h gt include lt errno h gt include socket h define Errno errno define FALSE 0 define TRUE 1 define Host_Port 5510 define MAXBUFLEN 100 int main void SOCKET Host Sock struct sockaddr in Host addr struct sockaddr in Client addr int hasMessage FALSE unsigned long pulArgp char buf MAXBUFLEN int addr len numbytes char ackmsg ACK if Host Sock socket PF INET SOCK DGRAM IPPROTO UDP INVALID SOCKET perror socket exit I Host_addr sin_family AF INET Host_addr sin_port htons Host_Port Host_addr sin_addr s_addr INADDR_ANY memset amp Host_addr sin_zero 0 8 ADAM 4500 Series User s Manual 4 75 Cha
85. 0 AM 2006 0649 6 02 00 AM 2006 0649 6 02 00 AM 2006 0649 6 03 00 AM 2006 0649 6 03 00 AM bytes free CFGIO EXE 35 328 06 19 2006 6 29p SOCKETP EXE 48 896 06 19 2006 6 30p REID EXE 6 528 06 19 2006 6 31p 7 file s 104 192 bytes 700 928 bytes free C transfer R D dhcpstat exze lt lt Transferring File gt gt start eu iii adam4soo 3 10 ADAM 4500 Series User s Manual zi mS 6 51PM Chapter 3 Program Download 3 4 Initialize the drive D to default settings Following steps will show you how to initialize the drive D to default settings for ADAM 4500 Series Controller The drive D of ADAM 4500 Series Controller will return to initial files and settings after this function is performed 1 Put switch into Initial mode and then reboot 2 Click the Adam 4500 Configuration button le x s UNO 3072 3074 Local Disk Removable Disk Removabl s Removable Disk Removabl a SDY SRAMDAY Removabl J Control Panel System Fol 3 Shared Documents File Folder 3 1 2006 3 My Documents File Folder 6 16 2006 File Folder 2006 0646 1 00 00 AM VVEBROOT File Folder 2006 0616 1 00 00 4M fS AUTORUN BAT 1KB MS DOSB 2006 0646 1 00 00 AM P 4x8796 cOM 13KB MS DOS A 2006 0646 1 00 00 AM CFGIO EXE 35KB Application 2006 0646 1 00 00 AM SOCKETP EXE 48KB Application 2006 0646 1 00 00 AM 7 objects l
86. 0 Series Utility Source Example DemoModbus directory Hardware configuration see figure below Host PC Downloafi program GF ADAM 4500 Series Controller Modbus TCP Client Modbus TCP Ethernet port ADAM 6051 Ethernet based DIO module Modbus TCP Server This example uses ADAM 4500 Series Controller as Modbus TCP client to connect to the ADAM 6051 support Modbus TCP protocol and can be a Modbus TCP server here and read the DI value of ADAM 6051 through Modbus TCP communication ADAM 4500 Series User s Manual 4 41 Chapter 4 Guidelines for Network Functions 1 Build DEMOTC EXE from DEMOTC PRJ under ADAM 4500 Series __Utility Source Example DemoModbus directory and download DEMOTC EXE onto drive D under root directory Put switch into Initial mode tf ADAM 4500 Series Utility Ver 1 14 E i amp 8 xj File Help Local System f ADAM 4500 Series E E yacon B DemoRS c 1KB CFil File Folder 1980 01 01 12 00 00 PM sf DEMORS DSK 3KB DSK VVEBROOT File Folder 1980 01 01 12 00 00 PM DEMORS EXE 41KB Appl Ss AUTORUN BAT 1KB MS DOS B 1980 01 01 12 00 00 PM E DemoRS PRJ 5KB PAJ E axe796 com 13KB MS DOS A 1980 01 01 12 00 00 PM DemoTC c 3KB OC Fil CFGIO EXE 35KB Application 1980 01 01 12 00 00 PM DEMOTC EXE 48KB Appl DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM E DemoTC PRJ 5KB PRAJ SOCKETP EXE 48KB Application 1
87. 00 4M e WEBROOT File Folder 2006 07 25 6 01 00 AM ce fs AUTORUN BAT 1KB MS DOSB 2006 07 25 6 01 00 4M TCLIENT EXE 35KB Applical TCP Client c 4KB CFile TCP_Server c 8KB CFile P TSERVER EXE 35KB Applical E TServer PRJ 5KB PRN File P UCLIENT EXE 35KB Applical Z UDP_Client c 4KB C File E UDP Server c 4KB CFile P USERVER EXE 34KB Applical 4x8796 cOM 13KB MS DOS A 2006 07 25 6 01 00 AM CFGIO EXE 35KB Application 2006 07 25 6 01 00 AM DEMORS EXE 41KB Application 2006 07 25 7 01 00 AM DEMOTS EXE 51KB Application 2006 07 25 6 01 00 AM SOCKETP EXE 48KB Application 2006 07 25 6 01 00 AM 35KB Application 2006 07 25 7 02 00 AM o object s 159 4 KB 9 object s 220 8 KB 622 592 bytes free 07 25 2006 6 1ip WEBROOT lt DIR gt 07 25 2006 6 1ip AUTORUN BAT 128 07 25 2006 6 1ip AX8796 COM 13 184 07 25 2006 6 1ip CFGIO EXE 35 328 07 25 2006 6 1ip SOCKETP EXE 48 896 07 25 2006 6 12p DEMOTS EXE 51 456 07 25 2006 6 19p DEMORS EXE 41 344 07 25 2006 7 1ip TSERVER EXE 35 712 07 25 2006 7 24p 9 file s 226 048 bytes 622 592 bytes free 4 Build TCLIENT EXE from TCLIENT PRJ under ADAM 4500 Series Utility Source Example TCP directory and download it onto dive D of the ADAM 4500 Series Controller which is the TCP client ADAM 4500 Series User s Manual 4 59 tf ADAM 4500 Series Utility Ver 1 14
88. 006 0619 7 01 00 AM File Folder 2006 1 KB MS DOS B 2004 MS DOS A 2004 1 Application 2004 1 Application 2004 1 gt Send To Cut Copy Create Shortcut Delete Properties 5 object s 7 object s 114 2 KB 735 232 bytes free Directory of D N CONF lt DIR gt 06 19 2006 7 11p WEBROOT lt DIR gt 06 19 2006 7 11p AUTORUN BAT 128 06 19 2006 edle AX8796 COM 13 312 06 19 2006 7 11p CFGIO EXE dinrJ2HsUn Mee 200 gei SOCKETP EXE 48 896 06 19 2006 wed DHCPSTAT EXE 19 328 06 19 2006 7 24p 7 file s 116 992 bytes 735 232 bytes free zi start S W 3 ili adamasoo MLS 7 36PM 4 Add DADHCPSTAT EXE in the autorun bat file After finishing SET FTPDIR D webRoot SET HTTP_DIR D webRoot SET SOCKETS D CONF I8 l ps picesmar EXE ADAM 4500 Series User s Manual 3 19 o 4500 6 Chapter 3 Program Download Update modified autorun bat file onto ADAM Series Controller by choose the autorun bat file in the left window and click the Download button HIT ADAM 4500 Series Utility Ver 1 13 File Help 15 xl ADAM 4500 Series EH re m valcom Name Size Type Modified Local System File Folder 2006 1 CONF File Folder 2005 06 19 7 01 00 AM MS DOS B 2004 WEBROOT File Folder 2006 0649 7 01 00 AM MS DOS A 2004 F AUTO
89. 006 07 25 7 03 00 4M lo object s 159 4 KB 10 object s 254 8 KB 587 776 bytes free Compiled Apr 13 2004 4 11 1525 Processing D CONF socket cfg if0 Packet driver at Ox60 using h w int 7 Unknown host O Hostname 10 0 0 2 if0 10 0 0 2 Net mask 255 0 0 0 D gt userver Wait for client send message 6 Run UCLIENT EXE add IP address of TCP server which you set in step 1 as parameter on another ADAM 4500 Series Controller which is the UDP client You can see the data sent from server B ADAM 4500 Series Utility Ver 1 14 E 81 x File Help Local System ADAM 4500 Series c Program Files Advantech 4D4M 4500 Series Ltiity So v o m Name Se Type Modified Name seje weed TCLIENT EXE 35KB Application 2006 07 2t CONF File Folder 1980 01 101 12 00 00 PM TCP_Client c 4KB C File 2005 08 0t Cj WEBROOT File Folder 1980 01 01 12 00 00 PM TCP_Server c SKB C File 2005 08 05 S AUTORUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM 1 TSERVER EXE 35KB Application 2006 07 25 4x8796 COM 13KB MS DOS A 1980 01 01 12 00 00 PM f TServer PRJ 5KB PAJ File 2004 08 12 E CFGIO EXE 35KB Application 1980 01 01 12 00 00 PM E UCLIENT EXE 35KB Application 2006 07 25 gt DEMORC EXE 23KB Application 1980 01 01 12 00 00 PM UDP_Client c 4KB C File 2005 08 05 DEMOTC EXE 48KB Application 1980 01 101 12 01 00 PM UDP_Server c 4KB C File 2005 08 05 SOCKETP EXE 48KB Application 198
90. 024 Status for tmp 0 tmp DataByteCount tmp adv_printf 02X HostData tmp j adv printf n j 5 104 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMTCP ReadlinputRegs Syntax int ADAMTCP ReadlnputRegs SOCKET SO int WaitMilliSec int Slave Addr int Startlndex int TotalPoint int ByteCount char wData Description 04 HEX command of Modbus TCP function code Parameter Desceription SO The socket connected to Modbus TCP server WaitMiliSec Set duration msec unit for the response from Modbus TCP server Slave_Addr Slave address StartIndex Starting address TotalPoint No of points ByteCount Byte count wData Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example This example demonstrates how to use ADAMTCP ReadlnputRegs to query remote Modbus TCP module such as ADAM 5000 TCP And here it queries all chanels of ADAM 5024 inserted in Slot 3 on the ADAM 5000 TCP if errnnSADAMTCP ReadlnputRegs amp SO 4500 50 0x01 0x19 0x08 amp DataByteCount HostData lt 0 perror ADAMTCP_ReadInputRegs n adv_printf errno is d n errno ADAM 4500 Series User s Manual 5 105 Chapter 5 Programming and Function Library ADAMTCP Disconnect
91. 06 19 7 01 00 AM croio EXE 35KB Application 2006 0649 7 01 00 AM SOCKETP EXE 48KB Application 2006 0649 7 01 00 AM File Folder Application Application Application Application Application Application Application B object s 1175 0 KB 6 objects 95 4 KB 754 688 bytes free Volume Serial Number is 3D46 1AE0 Directory of D N CONF DIR 06 19 2006 eal WEBROOT lt DIR gt 06 19 2006 T ale AUTORUN BAT 128 06 19 2006 ab AX8796 COM 13312580805 T9 HHh Y bm CFGIO EXE Sur dJZ2HAHR PS IHR Ta iip SOCKETP EXE 48 896 06 19 2006 ric bd 6 file s 97 664 bytes 754 688 bytes free E A start S Y ii adamasoo MS 7 33PM 3 18 ADAM 4500 Series User s Manual Chapter 3 Program Download 3 Find the autorun bat file under C Program Files Advantech ADAM 4500 Series Utility Source Drive_D Default_files on the left window on the Host PC Right click the autorun bat and choose Edit fill ADAM 4500 Series Utility Yer 1 13 ay File Help Local System ADAM 4500 Series Se EE E ve E valcom Size Type Modified CONF File Folder 2006 0649 7 01 00 AM C WwEBROOT File Folder 2006 0649 7 01 00 AM 5uroRUN BAT 1KB MS DOSB 2006 0649 7 01 00 AM 7 4x8786 coM 13KB MS DOS A 2006 0649 7 01 00 AM CFGIO EXE 35KB Application 2006 0649 7 01 00 AM bHcPsTAT EXE 19KB Application 2006 0649 7 02 00 AM SOCKETP EXE 48KB Application 2
92. 1 57a 4 file s 109 056 bytes 542 720 bytes free 2 Put switch into Normal mode and reboot Type cd webroot to enter Webroot directory Run FTP EXE add the FTP address of the FTP server you want to connect la x File Help Local System ADAM 4500 Series Nam Size Type Modified FTP EXE 44KB Application 2005 07 26 11 05 00 4M 44KB Application 2004 0471 7HrTPFTPD EXE B3KB Application 2006 07 25 6 01 00 AM 38KB Application 2004 05 27 45KB Application 2004 04 71 50KB Application 2004 04 12 50KB Application 2004 06 17 63KB Application 2004 04 1 1KB HTML Do 2004 06 0 El 106 5 KB 542 720 bytes free D gt cd webroot D WEBROOT gt ftp ftp advantech com tw 220 Microsoft FTP Service Username Please go directly to ncg7 for Network Computing P lei Pd for Embedded Computing Group aag for Web Appliance Group 4cpoZz for Core Platform Organization Your user name amp password is now the same as your NT logon what you use when you first turn on your computer but your user name needs to be input like this Advantech your name 220 Outside vendors amp customers of course will each need their own special Username 4 80 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 3 Login FTP server by typing your username and password Then you can start to enter FTP command to use the FTP server tf ADAM 4500 Series Utility
93. 176 bytes free C transfer R D WORKERWR EXE lt lt Transferring File gt gt lt lt Get ACK for EOT gt gt start S Y 2 ii adamasoo S ww 8 53PM 8 Click the Refresh button Check the drive D has been restored from the backup image file HIT ADAM 4500 Series Utility Ver 1 13 File Help Local System ADAM 4500 Series la Alafo z Name Size Type Modified Se LINO 3072 3074 Local Disk File Folder 2006 0649 7 01 00 AM s Removable Disk Removabl File Folder 2006 0649 7 01 00 AM w Removable Disk Removabl fs AUTORUN BAT 1KB MS DOS B 2006 0619 8 00 00 4M a ADY SRAMDRY Removabl P 4x8796 COM 13KB MS DOS A 2006 0649 7 01 00 AM G Control Panel System Fol cFGio ExE 35KB Application 2006 0649 7 01 00 AM Qo Shared Documents File Folder 2006 03 01 sockerP EXE 48KB Application 2006 0619 7 01 00 AM My Documents File Folder 2005 05 15 7 object s 10 byte s 6 object s 95 4 kB 754 688 bytes free Volume Serial Number is 3D46 1AE0 Directory of D N CONF lt DIR gt 06 19 2006 r gal WEBROOT lt DIR gt 06 19 2006 7 11p AUTORUN BAT 128 06 19 2006 8 08p AX8796 COM T3 ITZA UBS 19 HHh 7 11p CFGIO EXE SS 2g 2HNHl5 TS 2 HHBS giae SOCKETP EXE 48 896 06 19 2006 7 12p 6 file s 97 664 bytes 754 688 bytes free start S Y 3 ii adamasoo S ww 8 55PM 3 30 ADAM 4500 Series User s Manual 4 Guidelines for Network
94. 20 bytes 735 232 bytes free 4 A start 9 Y E iii Adam4500 7 49 PM 3 20 ADAM 4500 Series User s Manual Chapter 3 Program Download 7 Put switch into Normal mode and then reboot In Initial mode program listed in autorun bat will not automatically run after boot up it will automatically run after boot up only in Normal mode i 8 Heboot the ADAM 4500 Series Controller and check the terminal window to see if dhcpstat exe has been executed correctly fill ADAM 4500 Series Utility Yer 1 13 l l x File Help Local System ADAM 4500 Series C Program Files Advantech 4D4M 4500 Series Lltility So Modifie Name Size Type Modifiea File Folder 2006 1 CONF File Folder 2006 06 19 7 01 00 AM E autorun 1KB MS DOS B 2004 IC WEBROOT File Folder 2006 06 19 7 01 00 AM 1s 13KB MS DOS A 2004 amp uroRUN BAT 1KB MS DOSB 2006 0649 7 02 00 AM FGI 35KB Application 2004 1 7 4x8786 coM 13KB MS DOS A 2006 06 19 7 01 00 AM f SOCKETP 48KB Application 2004 1 cFGio EXE 35KB Application 2005 05 19 7 01 00 AM pHcPsTAT EXE 19KB Application 2005 06 19 7 02 00 AM 7 sockETP EXE 48KB Application 2006 06 19 7 01 00 AM E 5 object s 95 1 KB object s 114 4 KB 735 232 bytes free Hostname 192 168 1 4 if0 192 168 1 4 Net mask 255 255 255 0 Datalight Sockets DHCPSTAT v6 22 Revision 4 11 Copyright c 1989 2003
95. 255 0 0 0 D gt tclient 10 0 0 2 Received Hello world Received Received ADAM 4500 Series User s Manual 4 61 Chapter 4 Guidelines for Network Functions ICP SERVER C include lt stdio h gt include lt stdlib h gt ifdef MSC VER include lt malloc h gt else include lt mem h gt endif include lt string h gt include lt conio h gt include lt errno h gt include socket h define Errno errno define FALSE 0 define TRUE 1 Zdefine Host Port 5510 Zdefine Max Conn 40 Zdefine MAXDATASIZE 100 SOCKET remoteSocket Max Conn int WaitSocketCount Max Conn int socketTotal 0 int timeoutRelease FALSE void ReleaseClient int idx so int main void SOCKET Sock 4500 New Conn struct sockaddr in Host addr struct sockaddr in Client addr int sin_size int hasConnect hasMessage int maxSocket sidx New_Sidx numbytes sidx2 char buf MAXDATASIZE unsigned long pulArgp char str int tmpcount 1 if Sock 4500 socket AF_INET SOCK STREAM 0 INVALID SOCKET 4 62 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions perror socket exit I j Host_addr sin_family AF_INET Host_addr sin_port htons Host_Port Host_addr sin_addr s_addr INADDR_ANY memset amp Host_addr sin_zero 0 8 if bind Sock_4500 struct sockaddr amp Host addr sizeof struct sockaddr SOCKET_ERROR perror bind exit I j p
96. 35 328 06 19 2006 Zip SOCKETP EXE 48 896 06 19 2006 T L2p 6 file s 97 664 bytes 754 688 bytes free m start S W 3 iii adamasoo V ww 8 22PM ADAM 4500 Series User s Manual 3 25 Chapter 3 Program Download 7 Backup function will start to process TIT ADAM 4500 Series Utility Ver 1 13 amp x File Help Local System ADAM 4500 Series m 72g cov Se LINO 3072 3074 Local Disk s Removable Disk Removabl s Removable Disk Removabl gt Shared Documents File Folde S ADV SRAMDRV Removab FA averar co 126 MS DOS A 2006 06 19 7 01 00 AM gt Control Panel tea Advantech Image Worker JX ke application 2006 06 19 7 01 00 AM Adam 4500 Image Worker CONF File Folder 2006 0649 7 01 00 AM YVEBROOT File Folder 2006 0649 7 01 00 AM amp uTORUN BAT 1KB MS DOSB 2006 06 19 8 00 00 AM B Application 2006 0649 7 01 00 AM 3 My Documents File Folde Read Image Estimate time 10 minutes Help Backup Image 7 object s lo byte s AX8796 COM SOCKETP EXE C transfer R D lt lt Transferring F lt lt Get ACK for EOT gt gt D NWORKERRD 2 3 4 5 A start ayo iii Adam4500 Write Image Estimate time Bminutes Restore Image CFGIO EXE Please wait system is under making backup image 6 file s WB ac a vR 7C4 498 bytes free S ww 8 23PM 8 Click the OK button t
97. 35KB Application gt 10 object s 01 01 1980 128 01 01 1980 12205 13 184 01 01 1980 12 05a 357328 01 01 1980 12 05a 48 896 01 01 1980 12 05a 48 256 01 01 1980 12 10a 22 784 01 01 1980 12 00a 35 072 01 01 1980 12 08a 34 944 01 01 1980 12 01a 238 592 bytes 609 280 bytes free j ADAM 4500 Series User s Manual 4 73 Chapter 4 Guidelines for Network Functions 9 Put switch of the two ADAM 4500 Series Controllers into Normal mode and reboot the two controllers Run USERVER EXE on the ADAM 4500 Series Controller which is the UDP server i ADAM 4500 Series Utility Ver 1 14 E l xj File Help Local System ADAM 4500 Series E i Name Size Type Motion E TCLIENT EXE 35KB Applical CONF File Folder 2006 07 25 6 01 00 AM TCP_Client c 4KB C File Cj WEBROOT File Folder 2006 07 25 6 01 00 AM B TCP_Server c 8KB CFile amp uroRUN BAT 1KB MS DOS B 2006 07 25 6 01 00 AM Ei TSERVER EXE 35KB Applical 774x8786 coM 13KB MS DOS A 2006 07 25 6 01 00 AM E TServer PRJ BKB PR File I CFGIO EXE 35KB Application 2006 07 25 6 01 00 AM 1 UCLIENT EXE 35KB Applical 7 pEMORS EXE 41KB Application 2006 07 25 7 01 00 AM UDP_Client c 4KB CFile DEMOTS EXE 51KB Application 2006 07 25 6 01 00 4M UDP_Server c 4KB CFile SOCKETP EXE 48KB Application 2006 07 25 6 01 00 AM USERVER EXE 34KB Applical TSERVER EXE 35KB Application 2006 07 25 7 02 00 AM USERVER EXE 34KB Application 2
98. 4500 0x07ff lt 0 Desceription The socket connected to Modbus TCP server Set duration msec unit for the response Modbus TCP server Slave address Register address Preset Data No error occurs Time out error when receive modbus query message from Modbus TCP server Error occurs when send modbus query message Modbus TCP server Error occurs when receive modbus query message from Modbus TCP server 50 0x01 0x19 perror ADAMTCP_PresetSingleReg n ADAMTCP Disconnect amp SO 4500 return O j 5 98 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMModbusTCP Write Syntax bool ADAMModbusTCP Write SOCKET SO int WaitMilliSec int Slave Addr unsigned long i iStartAddr unsigned long i iEndAddr unsigned char i szData Description Presets values or forces coils into a sequence of holding registers 4X references or a sequence of coilds OX references Parameters Description SO The socket connected to Modbus TCP server WaitMilliSec The maximum time of ADAMModbusTCP_Write Slave Addr Address ID of slave device valid slave device addresses id are in the range of 0 247 decimal iStartAddr The start address of slave device i iEndAddr The end address of slave device szData The buffer of query data contents Return value ADAMModbusTCP_Write returns TRUE if it is successful On an error a value of FALSE will be return and the function Error Code can be u
99. 4500 Series Configuration g Lise Adam 4500 Series System Conf amp Init C3 WebRoot System Configuration 01 00 AM E dhepstat IP DHCP E httpget StaticIP c DHCP v Obtain DNS address automatically am Address ps fies fr fa Primary DNS I 3 B B ipsta E EMAIL Gateway 255 255 zss fo SENDMAIL FTP amp HTTP Configuration e FTP Update Successfully ID Password IE i Rights Change Dir Creat Del Dir Write File T i ReadFile HITTPFTPD EXE STET Update C transfer l ee en eee M System Initialization lt lt Get ACK POE v System Files HTTPFTP Server FTP Server HTTP Server Go 8 object s 1175 0 Post Files Use CGI Directory of d stat S Y 3 i adamasoo MMS 7 29PM 3 16 ADAM 4500 Series User s Manual Chapter 3 Program Download 5 Fill in the user name password and access right for FTP server and HTTP perform server the configuration FIITADAM 4500 Series Utility Ver 1 13 Click the Update File Help button to ADAM 4500 Series Local System amp amp e s z ee it E C Program Filesv amp dvantecF 2 we Ef Be xs m 72g cow gt i ane Adam 4500 Series System Conf amp Init C3 WebRo
100. 864 bytes 87 776 bytes free from UCLIENT PRJ under Series Utility Source Example T CP and download it onto drive D of the ADAM 4500 Series Controller which is the UDP client UP ADAM 4500 Series Utility Ver 1 14 File Help i81 xl Local System 7 TCLIENT EXE 35KB E TCP Client c 4KB TCP Server c SKB TSERVER EXE 35KB E TServer PRJ 5KB UCLIENT EXE 35KB E UDP Client c 4KB E UDP Server c 4KB P USERVER EXE 34KB xm Alafo z Modified 1880 01 01 12 00 00 PM 1980 01 01 12 00 00 PM 1980 01 01 12 00 00 PM 1980 0101 12 00 00 PM 1980 0101 12 00 00 PM 1980 01 01 12 00 00 PM 1980 01 01 12 01 00 PM 1980 0101 12 00 00 PM 1980 0101 12 00 00 PM 1880 01 01 12 00 00 PM 233 0 KB 609 280 bytes free 9 object s 159 4 KB AUTORUN BAT AX87965 COM CFGIO EXE SOCKETP EXE DEMOTC EXE DEMORC EXE TCLIENT EXE UCLIENT EXE 10 file s ADAM 4500 Series i Name sze Twe Application 2006 07 25 CONF File Folder C File 2005 08 08 C WEBROOT File Folder C File 2005 08 08 fS AUTORUN BAT 1KB MS DOS B Application 2006 07 25 1 AX8796 COM 13KB MS DOS A PRJ File 2004 08 1 P CFGIO EXE 35KB Application Application 2006 07 25 A DEMORC EXE 23KB Application C File 2005 08 0 pEMorC EXE 48KB Application C File 2005 08 08 SOCKETP EXE 48KB Application Application 2006 07 25 P TCLIENT EXE 35KB Application im UCLIENT EXE
101. 980 01 101 12 00 00 PM DemoTS c 2KB CFI E DEMOTS DSK 3KB DSK DEMOTS EXE 51KB Appl s DEMOTS OBJ 2KB OBJ E DemoTS PRJ 5KB PRAJ mod h 29KB HFi 17 object s 230 0 kB l object s 142 4 KB 702 976 bytes free Volume Serial Number is 3026 07C0 Directory of D N CONF DIR p1i 01 1980 12 05a WEBROOT lt DIR gt 01 01 1980 12 05a AUTORUN BAT 128 Wb ase eee AX8796 COM 13 184 01 01 1980 72 H5a CFGIO EXE 35 928 01 01 1980 12 053 SOCKETP EXE 48 896 01 01 1980 12 05a DEMOTC EXE 48 256 01 01 1980 12 10a 7 file s 145 792 bytes 702 976 bytes free zi 2 Put switch into Normal mode and then reboot Run DEMOTC EXE remember to add IP address of ADAM 6051 to launch Modbus TPC client on ADAM 4500 Series Controller You can get DI value of ADAM 6051 now amp ADAM 4500 Series Utility Yer 1 14 l 81 x File Help Local System ADAM 4500 Series EH Baj of Te BEY Sz e z ia OM2 z Name Size Type Modified DemoRS c CONF File Folder 1980 01 01 12 00 00 PM DEMORS DSK 3KB DSK WEBROOT File Folder 1980 01 01 12 00 00 PM EpEM RS EXE 41KB Appl e auroRUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM E DemoRS PRJ 5KB PAJ 4x8786 coM 13KB MS DOS A 1980 01 01 12 00 00 PM B DemoTC c 3KB CFil E cFaio EXE 35KB Application 1980 01 01 12 00 00 PM r1 DEMOTC EXE 48KB Appl DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM ej DemoTC PRJ 5KB PRAJ 7 soc
102. ADAM 4500 Series Ethernet enabled Communication Controller with I O Modules User s Manual Copyright Notice This document is copyrighted 1997 by Advantech Co Ltd All rights are reserved Advantech Co Ltd reserves the right to make improvements to the products described in this manual at any time without notice No part of this manual may be reproduced copied translated or transmitted in any form or by any means without the prior written permission of Advantech Co Ltd Information provided in this manual is intended to be accurate and reliable However Advantech Co Ltd assumes no responsibility for its use nor for any infringements upon the rights of third parties which may result from its use Acknowledgments ADAM 1s a trademark of Advantech Co Ltd IBM and PC are trademarks of International Business Machines Corporation Edition 2 0 May 2008 Table of Contents Chapter 1 System Overview ee eese ee eee Ms WUIMTPOGUGCION teh teased oust c RU k2 FeaAtUrES e 1 3 ADAM 4501 4501D Controllers Specification Chapter 2 Installation Guidelines 2 1 System RHeguiremenls oisi sow Casan rcp ieee vsvensewtedvinccdets 2 2 Hardware Installation 2 3 System Wiring and Connections er ERE 2 4 Software Installation ccce Chapter 3 1 0 Modules
103. AM w Removable Disk Removabl CONF File Folder 2006 06 19 7 01 00 AM w Removable Disk Removabl C WEBROOT File Folder 2005 06 19 7 01 00 4M se ADV SRAMDRV Removabl Fal aL ITORI INL R amp T 1KR MS DOS B 2006 0649 8 00 00 AM J Control Panel System Fol Advantech Image Worker XJ ms pos a 2006 06 19 7 01 00 AM Shared Documents File Folder amp dam 4500 Image Worker Application 2006 06 19 7 01 00 AM Estimate time 10 minutes m Write Image Estimate time 6minutes Restore Image E My Documents File Folder Pead Image Application 2005 06 19 7 01 00 AM elp 7 object s 0 byte s 4 KB 754 176 bytes free Directory of D N CONF lt DIR gt 06 19 2006 Ws Ep WEBROOT lt DIR gt 06 19 2006 fee dale AUTORUN BAT 128 06 19 2006 8 08p AX8796 COM 13 312 06 19 2006 bip CFGIO EXE 35 328 06 19 2006 pea SOCKETP EXE 48 896 06 19 2006 Talp 1253 DIR 06 19 2006 8 28p 7 file s 97 664 bytes 754 176 bytes free start S y 3 i adamasoo S ww 8 39PM There will be warning dialog window showing Make sure all files on drive D can be deleted Also make sure there is 10KB free space on drive D of ADAM 4500 Series Controller by the status bar at the bottom of the right window If everything is okay click the Yes button fll ADAM 4500 Series Utility Yer 1 13 B 18 x File Help Local System ADAM 4500 Series Alafo
104. AM 4500 Series a alel Alafo z Se UNO 3072 3074 Local Disk ss Removable Disk Removabl CONF File Folder 2006 0616 1 00 00 AM C9 WwEBROOT File Folder 2006 0616 1 00 00 AM a Removable Disk Removabl S AUTORUN BAT 1KB MS DOS B 2005 06 16 1 00 00 AM se ADY SRAMDRY Removabl P Ax8796 COM 13KB MS DOS A 2006 0616 1 00 00 4M D Coni Pane System Fol adjen zoosnens 1 0000 am Shared Documents File Folder ion 20060646 1 00 00 AM My Documents File Folder A i It needs at least 40 KB free space on Adam 4500 D drive Are you sure to continue 7 object s iD byte s Volume Serial Number is 314E 08D7 Directory of D N CONF DIR 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 EET PA CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free start S 2 Y ii adamasoo S ww 3 12PM 6 Built in example will be downloaded into the controller You can use this example to test the functionality of DIO on ADAM 4501 4501D ADAM 4500 Series amp ge s BN Alafo My Computer Name 1 Size Type Modified Sie Modified Se UNO 3072 3074 Local Disk CONF File Folder 2006 0616 1 00 00 AM w Removable Disk Removabl Cj WwEBROOT File Folder 2006 0616 1 00 00 A
105. CHO OFF CMON ee ee LT 3 D gt demorc init success Success Success Success 4 54 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions DEMORC C Zinclude stdio h Zinclude dos h include lt time h gt include RTU h define MAXDATASIZE 100 void main unsigned char HostData MAXDATASIZE int cnt 0 unsigned int tnpcnt 0 tmpcnt1 0 if Modbus_COM_Init COM2 Master unsigned long 9600 NO PARITY DATAS STOP1 0 d printf errori return j printf init success Nn wh le 1 cnt 4 if cnt 2 0 HostData 1 Ox0f HostData 0 Oxff j else HostData 1 0x00 HostData 0 0x00 j if cnt 10 cnt 0 Set 40568 status If ADAMRTU ForceMultiCoils COM2 0x02 Ox11 OxOc 0x02 HostData ADAM 4500 Series User s Manual 4 55 Chapter 4 Guidelines for Network Functions printf err code is Yod n Error Code printf fail send else printf Success An for tmpcnt 0 tmpcnt 50000 tmpcnt delay for tmpcntl 0 tmpcntl lt 4 tmpcntl 4 4 4 56 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 8 TCP Server and Client Example program TSERVER EXE and TCLIENT EXE Source file TCP SERVER C and TCP CLIENT C under ADAM 4500 Series Utility Source Example TCP directory Hardware configuration see figure below Download program COM Por
106. Chapter 5 Programming and Function Library shutdown ioctlsocket 5 178 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library gethostbyaddr Syntax struct hostent gethostbyadar const char pcAdar int len int type Description Gets host information corresponding to an address Parameters Description pcAdar A pointer to an address in network byte order len The length of the address which must be 4 for PF INET addresses type The type of the address which must be PF INET Return Value If no error occurs gethostbyaddr returns a pointer to the hostent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSAHOST NOT FOUND Authoritative Answer Host not found WSATRY AGAIN Non Authoritative Host not found Or SERVERFAIL WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO DATA Valid name nodata record of requested type Remarks gethostbyaddr 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 ADAM 4500 Series User s Manual 5 179 Chapter 5 Programming and Function Library shorth length char h addat list 5 180 ADAM 4500 Series User s Manual Chapter 5
107. DAM 4500 Series Controller DP Client Download program thernet Port ADAM 4500 Series Controller UDP Server This example uses one ADAM 4500 Series Controller as UDP client to connect to another ADAM 4500 Series Controller as UDP server They can exchange data between each other through UDP communication ADAM 4500 Series User s Manual 4 71 Chapter 4 Guidelines for Network Functions 1 Put switch of the two ADAM 4500 Series Controllers into Initial mode Click the Adam 4500 Configuration button to set P address for Server ADAM 4500 Series Controller amp ADAM 4500 Series Utility Yer 1 14 i l x File Help Local System Adam 4500 Series Configuration m Adam 4500 Serie s LINO 3072 3 Sy w MOBILE S D D6 07 25 5 04 00 AM 6 07 25 5 04 00 AM DI6 07 25 5 04 00 AM 6 07 25 5 04 00 AM D6 07 25 5 04 00 AM 6 07 25 5 05 00 AM 6 07 25 5 04 00 AM 6 07 25 6 00 00 AM Static IP C DHCP Address fio Jo Jo J2 Gateway P UM T T Update Shared Docu B M y Documen r FTP amp HTTP Configuration FIP HTTP ID ID Password Password Rights Change Dir Rights 7 Get Files l objec s Creat Del Dir Post Files Write File Use CGI Read File Update System Initialization v System Files HTTPFTP Se
108. Datalight Inc Portions copyright c GPvNO 2003 Sockets build 1525 Interface name if0 IP address 192 168 1 4 Net bits 24 Net mask 255 255 255 0 This interface is not using DHCP or BOOTP 4 d start S W 3 ili adamasoo WS 7 40PM 1 ADAM 4500 Series User s Manual 3 21 Chapter 3 Program Download Note There is another easier way to set program run automatically after boot up You don t need to modify the autorun bat on the host PC and download to ADAM 4500 Series Controller In this example put the switch into Initial Mode Download the program dhcpstat exe onto ADAM 4500 Series Controller as shown in step 2 of the previous method Then right click the program dhcpsiat exe on the right window and choose Set to AutoRun gt gt Adam 4500 It will modify the autorun bat this has the same effect as step 3 5 of the previous method HIT ADAM 4500 Series Utility Ver 1 13 i 18 x File Help ADAM 4500 Series oe EE BN 2 gi cow File Folder Cy wEBROOT File Folder 2006 06 19 7 01 00 AM 5uroRUN BAT 1KB MS DOSB 2006 0619 7 03 00 AM 7 4x8796 coM 13KB MS DOS A 2006 06 19 7 01 00 AM cFoio ExE 35KB Application 2006 06 19 7 01 00 AM ft CHC reae 4040 Application 2006 06 19 7 02 00 AM Fsoc she Directory Application 2006 06 19 7 01 00 AM ADAM Copy O Conf File Folder 2006 1 2006 0619 7 01 00 AM E autorun 1KB MS DOSB 2006 1 734x8736 13KB MS DO
109. E 63KB Application 2006 07 14 5 03 00 AM Application Application HTML Do 2 7 object s 257 5 KB 4 object s 183 9 KB 627 200 bytes free Local System ADAM 4500 Series D WEBROOT gt httpd r Sockets HITP RC Server v6 22 Revision 4 11 1525 Copyright c 1989 2003 Datalight Inc Portions copyright c GPvNO 2004 compiled 04 13 2004 Going resident D WEBROOT gt A start 5 Y ii adamasoo Sw 6 14PM 4 Type httpdemo to run HTTPDEMO EXE HII ADAM 4500 Series Utility Ver 1 13 8 amp 1 x File Help i isi c Program Files Advantech 4DAM 4500 Series Litility YSo i Nam Size Type Modified Application FTPD EXE 45KB Application 2005 07 1 4 6 00 00 4M Application HrTPD EXE 50KB Application 2006 0714 6 00 00 AM Application HTTPDEMO EXE 28KB Application 2006 0714 6 01 00 AM Application HTTPFTPD EXE 63KB Application 2006 0714 5 03 00 AM Application Application HTML Do gt i objectis 257 5 KB object s 183 9 KB 627 200 bytes free Local System ADAM 4500 Series Sockets HITP RC Server v6 22 Revision 4 11 1525 Copyright c 1989 2003 Datalight Inc Portions copyright c GPvNO 2004 compiled 04 13 2004 Going resident D WEBROOT gt httpdemo Going TSR D WEBROOT gt start S Wy 3 iii adamasoo Sw 6 15PM ADAM 4500 Series User s Manual 4 11 Chapter 4 Guidelines for Network Functions
110. EE LL ed x File Add Edit View Help TSAA see E Device Name Type Location Processing value Jpescription eT agl Coil Input 010001 Ready Device1 has 1 Tags 4 38 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions DEMOTS C include mod h Zinclude 4500drv h Zdefine DATASIZE 250 Zdefine sizeofShareMem 4000 int count 0 int main void SOCKET Sock 4500 int err code unsigned int Share Mem sizeofShareMem unsigned int tmpcnt 0 int tmpidx unsigned long div memset Share_Mem 0 sizeof Share_Mem if err_code ADAMTCP_ModServer_Create 502 5000 7 unsigned char Share_Mem sizeof Share_Mem 0 first step j printf error code is d n err code Timer Init tmpidx Timer Set 1000 printf Server started wait for connect n wh le 1 ADAMTCP ModServer Update second step return 0 NO packet return 1 has packet if tmArriveCnt tmpidx Timer Reset tmpidx disable GetDIO EB50 ID AllChannels 0 amp div ADAM 4500 Series User s Manual 4 39 Chapter 4 Guidelines for Network Functions Share Mem 0 div write DIO status to modbus address 40001 enable j ADAMTCP_ModServer_Release return 0 4 40 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 5 Modbus TCP Client Example program DEMOTC EXE Source file DEMOTC C under MADAM 450
111. ETSTATUS 6 Low level return parameters Return code in AX ADAM 4500 Series User s Manual 5 207 Chapter 5 Programming and Function Library HttpGetVersion Syntax int HttpGetVersion void Description The HttpGetVersion function gets the version of the running HTTP Server Parameter None Return value gt 0 Version number lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF GETVERSION 5 Low level return parameters Return code in AX 5 208 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library GetStackPointer GetStackSegment Syntax int GetStackPointer void int GetStackSegment void Description The GetStackPointer and GetStackSegment functions get the current Stack Pointer Segment Parameters None Return value Current value of Stack Pointer Segment ADAM 4500 Series User s Manual 5 209 Chapter 5 Programming and Function Library SetStackPointer SetStackSegment Syntax void SetStackPointer int iPointer void SetStackSegment int iSegment Description The SetStackPointer and SetStackSegment functions set the Stack Pointer Segment The stack pointer for callbacks is by default set to _SP 1000 the first time the HTTP API is called If you would need space on the stack or for some reason want to make it tighter set the stack pointer for callbacks manually Be careful not to overwrite used memory Parameters Description iPoi
112. File l8 object s 175 0 SEDIS C transfer 71 information x Update Successfully ID fuser x J Obtain DNS address automatically Primary DNS J Update et Files v Post Files JV Use CGI XTransferrin lt lt Get ACK for C transfer 7 XTransferrin M System Initialization Get ACK for 4 System Files HTTPFTP Server J FTP Server J HTTP Server Go A start ayo iii Adam4500 ADAM 4500 Series 3 mS 7 31PM User s Manual 3 17 Chapter 3 Program Download 3 6 Download and run the application program automatically after boot up ADAM 4500 series can automatically run program after boot up by including the program in the autorun bat file Following steps will demonstrate how to run dhcpstat exe automatically after boot up 1 Put switch into Initial mode and then reboot 2 Download the program dhcpstat exe under C Program Files Advantech ADAM 4500 Series Utility Source Drive_D Extension_ files onto ADAM 4500 Series Controller by click the Download button fill ADAM 4500 Series Utility Yer 1 13 81 x File Help ADAM 4500 Series IEEE E 2 gi cow size type Modified CONF File Folder 2006 0649 7 01 00 AM C9 WwEBROOT File Folder 2006 0649 7 01 00 AM 5uroRUN BAT 1KB MS DOSB 2006 0649 7 01 00 AM 7 4x8786 coM 13KB MS DOS A 2006
113. Function Library ADAMModbusRTU Read Syntax bool ADAMModbusHRTU Read int iPort int Slave Addr unsigned long iStartAddr unsigned long iEndAddr unsigned int o iByteOfResp unsigned char o szRespl Description Reads the On OFF status of OX X references coils or the binary contents of 3X 4X references registers in the slave Parameters Description iPort COM port number Slave_Addr Address ID of slave device valid slave device addresses id are in the range of 0 247 decimal iStartAddr The start address of slave device i iEndAddr The end address of slave device iTotalPoint The total number of coils regs to be read o iByteOfResp The total bytes of the response data contents o szHRHesp The buffer of response data contents Return value ADAMModbusRTU HRead returns TRUE if it is successful On an error a value of FALSE will be return and the function Error Code can be used to get the last error Example please refer the examples under C Program Files Advantech ADAM 4500 Series Utility Source ExampleModbusAppEx 5 86 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMRTU ModServer Create Syntax void ADAMRTU_ModServer_Create int slave addr unsigned char ptr mem unsigned int size of mem Description Create Modbus RTU Server function Parameters Description slave addr Slave address of Modbus RTU Server ptr mem Share memory size of mem Size of share memor
114. Functions S Create New Device under Advantech Modbus TCP OPC Server Set the correct IP address according to step 1 FZ ted Advantech Modbus TCP OPC Server J 18 x Name Type Location Processing value Descipion Device Properties xi Device Name Device IP Address 10 0 0 4 P Port Unit ID E Timeout 1000 Does not access the physical device Simulate 1 0 tee Ready 6 Right click on the new device you have just created and choose New Tag fig Untitled Advantech Modbus TCP OPC Server o LL ieri xj File Add Edit View Help seje ta a Name Type Location Processing value Descipion Delete Mew Group Properties Creates a new Tag Device1 has 0 Tags ADAM 4500 Series User s Manual 4 37 ra Chapter 4 Guidelines for Network Functions Configure the Tag Property Brg Untitled Advantech Modbus TCP OPC Server 81 x File Add Edit View Help amp e Gal jen Device Name Type Location Processng value Description x Description Cancel Location fol Input Coil read only m Data Type Er M Number of Bytes E Scaling Enable Settings Simulation signal Ramp X Ready Device1 has 0 Tags You can see the value of address 40001 from Modbus TCP server on ADAM 4500 Series Controller fig Untitled Advantech Modbus TCP OPC Server
115. If how is 0 subsequent receives on the socket will be disallowed This has no effect on the lower protocol 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 In no case will an ICMP error packet be generated If how is 1 subsequent sends are disallowed For TCP sockets a FIN wil 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 5 174 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Comments shutdown does not block regardless of the SO LINGER setting on the socket An application should not re use a socket after it has been shut down See Also connect socket ADAM 4500 Series User s Manual 5 175 Chapter 5 Programming and Function Library Socket Syntax SOCKET socket int af int type int protocol Description Creates a socket Parameters af An address format specification The only format currently supported is PF_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 specify a protocol Return Value If no error occurs socket returns a desc
116. M w Removable Disk Removabl fS AUTORUN BAT 1KB MS DOS B 2006 0616 1 00 00 AM s ADV SRAMDRV Removabl P axe796 COM 13KB MS DOS A 200690646 1 00 00 AM G Control Panel System Fol Q EX 35KB Application 2006 0646 1 00 00 AM Shared Documents File Folder 3 1 200598 REID EXE P amp aplication 2006 0649 3 00 00 AM C3 My Documents Fi FEE xi 05519 3 00 00 AM 06 16 1 00 00 4M Description jaoi 4D0 Ethernet based Controller pi3 pi2 pr1 Dio doa poo z mu Base e lelelele e o oFoo 4 7 object s 0 byte s C transfer R D lt lt Transferring File gt gt ssc eee lt lt Get ACK for EOT gt gt C transfer R D SIMU4501 EXE lt lt Transferring File gt gt lt lt Get ACK for EOT gt gt D REID D simu4501 or 3 start x Y Wii Adam4500 mS 6 34PM fFAL 7 MVI T7JUU VOIIGo UOUCI oO IVICIHI IUCGI Chapter 3 Program Download 7 Click the Launch Terminal button for launching terminal emulation function You can type DOS command in the termination window to communicate with ADAM 4500 Series Controller HIT ADAM 4500 Series Utility Ver 1 13 l xj File Help Local System Nam 1 Sie Type z LINO 3072 3074 Local Disk Modified CONF File Folder 2006 06 19 6 02 00 4M Cj WEBROOT File Folder 2006 0619 6 02 00 AM w Removable Disk Removabl Removable Disk Removabl
117. MAKEMAIL Gateway J SENDMAIL EA ping Information XI FT EE Configuration i System initial Successfully ID Password Rights Change Di Creat Del Dir Write File Read File System Initialization IF System Files HTTPFTP Server 7 FTP Server HTTP Server y start Y iii adamasoo MS 7 23PM 4 8 object s 175 Post Files Use CGI ADAM 4500 Series User s Manual 3 13 A Chapter 3 Program Download The directory of drive D will be refreshed as following picture HIT ADAM 4500 Series Utility Ver 1 13 File Help 18 x Local System ADAM 4500 Series C Program Files 4Advantech 4DAM 4500 Series Litility YSo w Name Size Type Modifie O w ebRoot File Folder 2006 1 Ef dhepstat 19KB Application 2004 1 httpaet 39KB Application 2004 1 e 5uroRUN BAT ista 25KB Application 2004 1 f 4x8796 cOM E3ipstat 22KB Application 2004 1 Loo EXE IMAKEMAIL 28KB Application 2004 1 ESISENDMAIL 24KB Application 2004 1 1 xping 20KB Application 2004 1 E re IB gi cow File Folder 2006 0649 7 01 00 AM File Folder 20060649 7 01 00 AM MS DOS B 2006 0619 7 01 00 AM MS DOS A 2006 0619 7 01 00 AM Application 2006 0649 7 01 00 AM Application 2006 0649 7 01 00 AM B object s 175 0 KB l6 object s 95 4 kB 751 616 by
118. ME Mode 0x01 Block mode duMode duMode UnBlock ede nn UnBlock mode 5 42 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO SendBytes Syntax INT SIO SendBytes UCHAR i ucPort UINT i uinBytes UCHAR i ucDataBuf Description To send character s to a specified COM port Parameter Description ucPort The Port number you want to send see remarks i uinBytes Number of bytes to be sent i ucDataBuf A buffer for sending data Return value If success return the number of bytes have been sent If fail return a negative number as follows No Such Port 3 Remarks COM COM Teron COMS COMS ADAM 4500 Series User s Manual 5 43 Chapter 5 Programming and Function Library SIO GetAvaiRecvBytes SIO GetAvaiSendBuf Syntax INT SIO_GetAvaiRecvBytes UCHAR i ucPort INT SIO GetAvaiSendBuf UCHAR i ucPort Description SIO GetAvaiRecvBytes Returns the number of bytes in input buffer SIO GetAvaiSendBuf Returns the number of bytes in output buffer Parameter Description ucPort The Port number you want to use see remarks Return value SIO GetAvaiRecvBytes If success return the number of bytes data in input buffer If fail return a negative number as follows No Such Port 3 SIO GetAvaiSendBuf If success return the number of remaining available bytes space in output buffer If fail return a negative number as follows No Such Port 3 Remarks C
119. N BAT 1KB MS DOSB 2006 07 25 6 01 00 AM E DemoR S PRJ 5KB PRJ 4X8796 COM 13KB MS DOS A 2006 07 25 6 01 00 AM DemoTC c 3KB CFil 7 croio ExE 35KB Application 2006 07 25 6 01 00 AM DEMOTC EXE 48KB Appl DEMOTS EXE 51KB Application 2006 07 25 6 01 00 4M E DemoTC PRJ 5KB PRJ SOCKETP EXE 48KB Application 2006 07 25 6 01 00 AM E DemoTS c 2KB CFil i DEMOTS DSK 3KB DSK DEMOTS EXE 51KB Appl DEMOTS OBJ 2KB OBJ E DemoTS PRJ 5KB PRJ mod h 29KB H Fi 17 objects 230 0 KB 7 objects 145 5 KB 699 904 bytes free 07 25 2006 lip BAT 128 07 25 2006 1i1p COM 13 184 07 25 2006 lip EXE 35 328 07 25 2006 lip EXE 48 896 07 25 2006 12p EXE 51 456 07 25 2006 19p 7 file s 148 GQ hwvtes 699 904 bytis free D gt demots Server started wait for connect 4 Launch Advantech Modbus TCP OPC Server ir Accessories gt ir Advantech gt A Documents gt f Advantech Automation gt p D sonn i If Powerview gt Internet Explorer o Search gt SS Outlook Express WinRAR gt pen and Suppor IM Advantech Adam OPC Server gt o Em a I Advantech ADAMView v al Advantech Modbus TCP OPC Server Log Off Administrator ir Advantech Modbus OPC Server 1 0 gt 2 Modbus OPC Server s Help c Y 77 OPC Browser Client 5E fo Turn Off Computer d staet 1j P 2 lii adamasoo lil Adamason WE 7 45 em 4 36 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network
120. None 5 32 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Ver Syntax void Ver char vstr Description Check Utility Library version Parameter Description vstr Pointer to array of Utility Library version information Return value None Example char library ver 20 void main void Ver library ver adv printf The version of utility library is s n library ver ADAM 4500 Series User s Manual 5 33 Chapter 5 Programming and Function Library 5 3 2 I O Module Functions HIO LIB InitDIFilter Syntax void InitDIFilter int iCh unsigned int MIN Lo Width unsigned int MIN High Width Description Set time interval of digital filter for DI channel Parameter Description iCh Channel no 0 4 MIN Lo Width Time interval of DI filter for Low state 5 65535 msec MIN High Width Time interval of DI filter for High state 5 65535 msec Return Value None Remarks Reference Data Time Interval Cut off Frequency 5 34 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library GetDIO for DI only SetDO Syntax UCHAR GetDIO UCHAR i ucModulelD UCHAR i ucMode UCHAR i ucChannel ULONG o ulValue UCHAR SetDO UCHAR i ucModulelD UCHAR i ucMode UCHAR i ucChannel ULONGii ulValue Description Read Write the value of digital input ouput channels Parameter Description i ucModulelD Module ID i ucMode SingleChan
121. OM COM col2 CcOM eon COM3 COM3 cCOM COM 5 44 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO PurgeBuf Syntax CHAR SIO PurgeBuf UCHAR i ucPort UCHAR i ucFlag Description User can clear input buffer and output buffer together with argument ucFlag Parameter Description ucPort The Port number you want to use see remarks ucFlag Decide which buffer you want to clear You can choose to clear input buffer or output buffer see remarks Return value If success return 0 If fail return a negative number as follows No Such Port 3 Illegal Setting 5 Remarks COM COM i ucPon COM2 COM2 COM4 ADAM 4500 Series User s Manual 5 45 Chapter 5 Programming and Function Library COM Port Communcation Example 1 Refer to C Program Files Advantech ADAM 4500 Series Utility Source Example Basic_Function ExCOM C for this example ifdef Product_ 5510 include 5510drv h elif defined Product_4500 include 4500drv h endit include lt conio h gt include lt dos h gt define DataLen50 define RecvDataLen 30 void main UCHAR tmpCOM Idx 0 CHAR Data DataLen UCHAR Mode 0 0 gt Receive 1 gt Send CHAR VerStr 30 UCHAR RecvMode UCHAR nByte 0 nTotalByte 0 printf Arthur New COM Port Library Test 3 3 n Ver COMLib VerStr printf Com Library Version s n VerStr printf Enter receive mode 1 Block
122. P axe796 COM 13KB MS DOS A 2006 07 25 6 01 00 4M E DemoRS PRJ 5KB PRAJ CFGIO EXE 35KB Application 2006 07 25 6 01 00 AM f DemoTC c 3KB CFil DEMOTS EXE 51KB Application 2006 07 25 6 01 00 AM DEMOTC EXE 48KB Appl sockerP EXE 48KB Application 2006 07 25 6 01 00 AM E DemoTC PRJ 5KB PRJ DemoTS c 2KB OC Fil sj DEMOTS DSK 3KB DSK DEMOTS EXE 51KB Appl DEMOTS OBJ 2KB OBJ E DemaTS PRJ 5KB PRJ z 29KR_ H z 17 object s 230 0 KB object s 145 5 KB 699 904 bytes free Volume Serial Number is 0C22 19E1 Directory of D CONF DIR 07 25 2006 6 11p WEBROOT lt DIR gt 07 25 2006 6 1ip AUTORUN BAT 128 07 25 2006 6 1ip AX8796 COM 13 184 07 25 2006 6 1ip CFGIO EXE 35 328 07 25 2006 6 11p SOCKETP EXE 48 896 07 25 2006 6 12p DEMOTS EXE 51 456 07 25 2006 6 19p 7 file s 148 992 bytes 699 904 bytes free E ADAM 4500 Series User s Manual 4 35 Chapter 4 Guidelines for Network Functions 3 Put switch into Normal mode and then reboot Under the root directory run DEMOTS EXE This will launch Modbus TCP server on ADAM 4500 Series Controller m ET la x File Help C Program Files Advantech 4D4M 4500 Series Lltility So re emt ERAB Name Size Type a Name sze Twe Modtea DemoRS c 1KB CFil CONF File Folder 2006 07 25 6 01 00 AM f DEMORS DSK 3KB DSK C WEBROOT File Folder 2006 07 25 6 01 00 4M DEMORS EXE 41KB Appl amp uroRU
123. P server which you set in step 1 as parameter on another ADAM 4500 Series Controller which is the TCP client You should see the data received amp ADAM 4500 Series Utility Yer 1 14 NN l x File Help Local System ADAM 4500 Series Saj a e e z ia Mz z C Program Files Advantech 4DAM 4500 Series Litility YSo w v Name Size Type Modified Name Size Type Moditien TCLIENT EXE 35KB Application 2006 07 25 CONF File Folder 1980 01 01 12 00 00 PM TCP Client c 4KB CFile 2005 08 0t Cj WEBROOT File Folder 1980 01 01 12 00 00 PM TCP_Server c 8KB C File 2005 08 05 S AUTORUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM 7 TSERVER EXE 35KB Application 2006 07 25 4x8796 cOM 13KB MS DOS A 1980 01 01 12 00 00 PM f TServer PRJ 5KB PR File 2004 08 12 El cFaio EXE 35KB Application 1980 01701 12 00 00 PM UCLIENT EXE 35KB Application 2006 07 25 pEMORC EXE 23KB Application 1980 01 01 12 00 00 PM LUDP Client c 4KB CFile 2005 08 05 DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM UDP_Server c 4KB C File 2005 08 05 SOCKETP EXE 48KB Application 1980 01 01 12 00 00 PM UsERVER EXE 34KB Application 2006 07 2 TcLiENT EXE 35KB Application 1980 01 01 12 00 00 PM 9 object s 159 4 KB 9 object s 198 9 KB 644 608 bytes free Processing D NCONFNsocket cfg if0 Packet driver at 0x60 using h w int 7 Unknown host Q0 Hostname 10 0 0 3 ifo 10 0 0 3 Net mask
124. Programming and Function Library The members of this structure are Element Usage h name Official name of the host PC h aliases A NULL terminated array of alternate names h addrtype The type of address being returned for SOCKETS this is always PF INET h length The length in bytes of each address for PF INET this is always 4 h addr list A N ULL terminated list of addresses for the host Addresses are returned in network byte order The macro h_addr is defined to be h addr list O for compatibility with older software The pointer which is returned points to a structure which is allocated by SOCKETS The application must never attempt to modify this structure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls See Also gethostbyname ADAM 4500 Series User s Manual 5 181 Chapter 5 Programming and Function Library gethostbyname Syntax struct hostent gethostbyname const char pszName Description Gets host information corresponding to a hostname Parameters Description PszName A pointer to the name of the host Return Value If no error occurs gethostbyname returns a pointer to the hostent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSAHOST NOT FOUND Authorit
125. R BOOL If true the SO LINGER TRUE option is disabled SO DONTROUTE BOOL Routing is disabled FALSE SO ERROR int Retrieve error status 0 and clear SO KEEPALIVE BOOL Keepalives are being sent FALSE SO LINGER struct linger Returns the current linger onoff is 0 options SO OOBINLINE BOOL Out of band data is being FALSE received in the normal data stream SO RCVBUF int Buffer size for receives 1460 SO REUSEADDR BOOL The socket may be bound FALSE to an address which is already in use SO SNDBUF int Buffer size for sends 1460 SO TYPE int The type of the socket e g As created SOCK STREAM TCP NODELAY BOOL Disables the Nagle algorithm FALSE for send coalescing ADAM 4500 Series User s Manual 5 135 Chapter 5 Programming and Function Library Calling getsockopt with an unsupported option will result in an error code of ENOPROTOOPT being returned from WSAGetLastError See Also setsockopt socket 5 136 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library htonl Syntax u long htonl u long ulHostlong Description Converts au long from host to network byte order Parameters Description ulHostlong A 32 bit number in host byte order Return Value htonl returns the value in network byte order Remarks This routine takes a 32 bit number in host byte order and returns a 32 bit number in network byte order See Also htons ntohl ntohs ADAM 4500 Series User s Manual 5 137
126. RUN BAT 1KB MS DOS B 2005 06 19 7 02 00 AM Application 200 7 4x8786 cOM 13KB MS DOS A 2006 0649 7 01 00 AM Application 200 f CFGIO EXE 35KB Application 2006 0649 7 01 00 AM DHCPSTAT EXE 19KB Application 2005 0649 7 02 00 AM Pa oocvcm ove Ao fi lim mie O05 057 g T 01 DO AM File transfer Transferring C Program Files 4dvantech 4DAM 4500 Series Ultility S ot File count fi H Progress 5 object s 95 1 kB AX8796 COM CFGIO EXE SOCKETP EXE DHCPSTAT EXE 7 file s 19 328 06 19 2006 7 24p 117 120 bytes 735 232 bytes free C transfer R D autorun bat lt lt Transferring File gt gt lt lt Get ACK for EOT gt gt mS 7 39PM A start ey iii Adam4500 Click the Launch terminal Terminal button for launching emulation function HIT ADAM 4500 Series Utility Ver 1 13 File Help Local System Cont File Folder 2006 06 1E E autorun 1KB MS DOS B 2006 06 15 2x8796 13KB MS DOS A 2004 08 2 FIcraio 35KB Application 2004 04 2 sockETP 48KB Application 2004 04 1 gt 5 object s 95 1 KB 7 objects 114 3 KB 735 232 bytes free Directory of D CONF DIR 06 19 2006 7 11p WEBROOT lt DIR gt 06 19 2006 fee thal AUTORUN BAT 156 06 19 2006 7 38p AX8796 COM 1372312 06 15 2006 bip CFGIO EXE 35 328 06 19 2006 7 11p SOCKETP EXE 48 896 06 19 2006 bp DHCPSTAT EXE 197328 06 19 2006 7 24p 7 file s 117 0
127. RespByteCount Resp From Server Now the RespByteCount should report this query has get 16 bytes data But where is the data The answer is quite simple as follows Resp From Server 0 gt 40001 Hi byte Resp From Server 1 gt 40001 Lo byte Above is the conpect how to use Modbus protocol and we also provide examples for reference please refer the examples under C Program Files Advantech ADAM 4500 Series Utility Source Example ModbusAppEx ADAM 4500 Series User s Manual 5 71 Chapter 5 Programming and Function Library Note Modbus libraries come from Modbus standard protocol and every function call can be mapped to a Modbus function For example ADAMRTU ReadCoilStatus function is mapped to Modbus Function code 01 Read Coil Status The following is the list of supported Modbus function codes Modbus Function Codes Related Modbus Libraries ADAMRTU ReadCoilStatus OP REAG COU SIAS ADAMTCP ReadcCoilStatus ADAMRTU ReadinputStatus 02 Read Input Status ADAMTCP ReadinputStatus ADAMRTU ReadHoldingRegs VP TISSU THUS Mediate ADAMTCP ReadHoldingRegs ADAMRTU ReadinputRegs 04 Read Input Registers ADAMTCP ReadinputRegs 05 Force Single Coil 06 Preset Single Register 15 Force Multiple Coils 16 Preset Multiple Registers Moreover we also provide four advanced function calls for beginners The Modbus function 01 02 03 04 can be simply integrated into one read function as ADAMModbusHRTU Read for Modbus RTU or
128. S A 2004 1 EA creo 35KB Application 2004 1 f SOCKETP 48KB Application 2004 1 ADAM Paste Delete Rep 5 object s 95 1 KB object s 114 2 KB 735 232 bytes free BAT 128 06 19 2006 WES AX8796 COM Us pests Lae 2U05 ILS CFGIO EXE 35 328 06 19 2006 Vip SOCKETP EXE 48 896 06 19 2006 We DHCPSTAT EXE 19 328 06 19 2006 7 24p 7 file s 116 992 bytes 735 232 bytes free z A start 2 WY ii adamasoo MLS 7 43PM After that click the Launch Terminal button as shown by steps 6 of previous method Put the switch into Normal mode and then reboot Now you should see the terminal window the same as steps 8 of previous method 3 22 ADAM 4500 Series User s Manual Chapter 3 Program Download 3 7 Backup drive D as image file Following steps demonstrate how to backup drive D as image file 1 2 Put switch into Initial mode and then reboot Click the Refresh button You can see latest files in drive D of ADAM 4500 Series Controller by the right window HII ADAM 4500 Series Utility Ver 1 13 File Help il81 xl Local System Nam Size Type Se UNO 3072 3074 Local Disk s Removable Disk Removabl s Removable Disk Removabl a ADV SRAMDRYV Removabl Modified e Control Panel System Fol ce Shared Documents File Folder 3 1 2006 3 My Documents File Folder 6 16 2006 7 object s fr byte s
129. SI pcBuf CX iCount Low level return parameters Return code in AX ADAM 4500 Series User s Manual 5 205 Chapter 5 Programming and Function Library HttpSubmitFile Syntax int HttoSubmitFile int Handle char far pszFileName Description The HttpSubmitFile function is used to submit a file to be sent to the client in response to a request The file will be logically appended to any data already sent using HttpSendData The file should not be exclusively opened when it is submitted After it is transmitted transmit upcalls will be issued normally This gives the user the ability to send any number of files on the connection with arbitrary data in between Parameter Description iHandle Handle passed in pfsHttpParams pszFileName Far pointer to name of file to submit Return value 0 OK lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF_SENDFILE 4 BX iHandle DS SI pszFileName 5 206 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library HttpGetStatus Syntax int HttpGetStatus void Description The HttpGetStatus function gets the number of connections to the server It must also be used as a polling function when the server IS running in passive mode to dequeue and handle pending requests Parameters None Return value 220 Number of connections to server lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF G
130. SOCKETS has detected that the network subsystem has failed EACCES The requested address is a broadcast address but the appropriate flag was not set EFAULT The pcBuf argument is not in a valid part of the user address space ENETRESET The connection must be reset because SOCKETS dropped it ENOBUFS SOCKETS reports a buffer deadlock ENOTCONN The socket is not connected ENOTSOCK 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 send on a socket after shutdown has been invoked with how set to 1 or 2 EWOULDBLOCK The socket is marked as non blocking 5 160 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Librar EMSGSIZE and the requested operation would block The socket is of type SOCK DGRAM andthe datagram is larger than the maximum supported by SOCKETS ADAM 4500 Series User s Manual 5 161 Chapter 5 Programming and Function Library EINVAL The socket has not been bound with bind ECONNABORTED The virtual circuit was aborted due to timeout or other failure ECONNRESET The virtual circuit was reset by the remote side Remarks 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 If the data is too long to p
131. Ver 1 14 l xj File Help Local System ADAM 4500 Series ER n Se 2 EE ei z h1 z Name Size Type Modified 4DAM E 38KB Application 2004 05 2 FTP EXE 44KB Application 2006 07 26 11 05 00 AM ftp exe 44KB Application 2004 04 1 HTTPFTPD EXE 63KB Application 2006 07 25 6 01 00 AM ftpd exe 45KB Application 2004 04 12 E Pt httpd ex 50KB Application 2004 04 1 1H DEM 50KB Application 2004 06 17 E httpitpd exe 63KB Application 2004 04 1 amp dam HTM 1KB HTML Do 2004 06 0 A 7 object s 287 3 KB 2 object s 106 5 KB 542 720 bytes free D NWEBROOT ftp ftp advantech com tw 220 Microsoft FTP Service Username Please go directly to ncg7 for Network Computing Pici Pd for Embedded Computing Group Zwag for Web Appliance Group Z cpoZz for Core Platform Organization Your user name amp password is now the same as your NT logon what you use when you first turn on your computer vut yvur uoti unawe BEES tu Me Lipul Line Ud Se Advantech your name 220 Outside vendors amp customers of course will hach need their own special Username advantech kunyu lee Password XXXXXXXX 230 I advantech kunyu lee logged in ftp ADAM 4500 Series User s Manual 4 81 Programming and Function Library Chapter 5 Programming and Function Library 5 1 Introduction User designed ADAM 4500 Series Controller application programs make use of ADAM 4500 Series lib
132. WaitMilliSec int Slave Addr int StartReg int TotalReg int TotalByte unsigned char Data Description 10 HEX command of Modbus TCP function code Parameters Desceription SO The socket connected to Modbus TCP server WaitMilliSec Set duration msec unit for the response from Modbus TCP server Slave_Addr Slave address StartReg Starting address TotalReg No of registers TotalByte Byte count szData Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example HostData 0 0x07 HostData 1 0x00 HostData 2 0x07 HostData 3 0x00 IffADAMTCP PresetMultiRegs amp SO 4500 50 0x01 0x19 0x02 4 HostData lt 0 perror ADAMTCP_PresetMultiRegs n ADAMTCP_Disconnect amp SO_ 4500 return O 5 96 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAM 4500 Series User s Manual 5 97 Chapter 5 Programming and Function Library ADAMTCP PresetSingleReg Syntax int ADAMTCP PresetSingleReg SOCKET SO int WaitMilliSec int Slave Addr int Reglndex int Data Description 06 HEX command Modbus TCP function code Parameters SO WaitMillisec from Slave_Addr RegIndex Data Return value TRUE 0 Example IRKADAMTCP PresetSingleReg amp SO
133. Y LIB adv printf Syntax void adv printf char pFormat Description Print string to console This function has the same usage as printf function However it has lower priority to be executed Parameter The same as printf of standard Borland C 3 0 library function Return value None Example include 4500drv h void main void j Remarks If printf function is put within while loop such as Modbus RTU server function it will decrease the performance of server function due to higher priority of print So it is strongly recommended that uses adv printf instead which has lower priority than printf adv printf Hello this is for test 5 12 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMdelay Syntax void ADAMdelay unsigned short msec Description Delays program operation by a specified number of milliseconds Parameter Description msec From 0 to 65535 Return value None Example include 4500drv h void main void codes placed here by user ADAMdelay 1000 delay 1 sec codes placed here by user j Remarks ADAMDelay will possibly decrease the so it is recommended to use for loop instead performance ADAM 4500 Series User s Manual 5 13 Chapter 5 Programming and Function Library Get BoardID Syntax unsigned char Get BoardlD void Description Gets the ID number of EB50 built in I O board Par
134. _file pass password pasv on off put local_file s remote_file Pwd quit quote remote_command args rmdir remote_directory rnfr existing filename rnto new filename site sub Command size file shell stat System type ila user username verbose on off FTP 6 6 ADAM 4500 Series User s Manual Description Cancel an incomplete transfer Put a file at the server but append it if the file exists Synonym for type a Synonym for type i Synonym for quit Synonym for cwd Change server directory Delete a server file Synonym for list Synonym for quit Transfer a file from the server in the current mode type Synonym for type i Synonym for nlst Perform a local change directory Give a local directory listing Give a long directory listing Synonym for get Create a server directory Synonym for put Give a short names only directory listing Password for username Report or change the status of the passive transfer mode to enable firewall friendly file transfers The SOCKETS FTP client always tries to switch passive mode on at the start of a session Transfer a file to the server in the current mode type Print working directory at server Terminate FTP session Send a command to the server without any interpretation Hemove delete a server directory Rename a file command 1 of 2 Rename a file command 2 of 2 Send server specific commands Report the file size in bytes
135. a For sockets of type SOCK_STREAM as much information as_ is currently available up to the size of the buffer supplied is returned If the socket has been configured for in line reception of out of band data socket option SO OOBINLINE and out of band data is unread only out of band data will be returned The application may use the ioctlsocket SIOCATMARK to determine whether any more out of band data remains to be read 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 the excess data is lost and recv returns the error EMSGSIZE 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 SOCKET ERROR is returned with the error code set to EWOULDBLOCK The select call 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 a recv will complete immediately with O bytes received If the connection has been reset a recv will fail with the error ECONNRESET iIFlags 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 iF ags parame
136. a certain CGI environment variable in your otherwise static document you can go through the trouble of writing a CGI program that outputs this small amount of virtual data Or better yet you can use a powerful feature called Server Side Includes or SSI Server Side Includes are directives which you can place into your HTML documents to output such data as environment variables and file statistics For a detailed introduction please visit http www ora com info cgi ch05 html A simple yet powerful interface is provided to perform Server Side Includes SSI tasks A user only has to implement one predefined function and make use of only four API functions to unlock the power of SSI The working of the interface is described at the 5 196 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library top of the header file ssi h To use include ssicgi c in your project and include ssi h in your source files Take a look at ss c for a simple example ADAM 4500 Series User s Manual 5 197 Chapter 5 Programming and Function Library Extention API Examples Five very simple examples are included to demonstrate the usage of the Extention API Source code is included as well as make files Put all htm and exe files in the HITP_DIR directory and start HTTPD Load all the cgi programs you may use cgi bat All is in place now and the examples may be accessed through index htm The first four examples may operate in on
137. a single set of twisted pair cables Parallel connected nodes true multi drop ADAM 4500 Series Controller is fully isolated and use just a single set of twisted pair wires to send and receive Since the nodes areconnected in parallel they can be freely disconnected from the host without affecting the functioning of the remaining nodes An industry standard shielded twisted pair is preferable due to the high noise ratio of the environment When nodes communicate through the network no sending conflicts can occur since a simple command response sequence is used There is always one initiator with no address and many slaves with addresses n this case the master is a personal computer that is connected with its serial RS 232 port to an ADAM RS 232 RS 485 converter The slaves are the ADAM 4500 Series Controller When systems are not transmitting data they are in listen mode The host computer initiates a command response sequence with one of the systems Commands normally contain the address of the module the host wants to communicate with The system with the matching address carries out the command and sends its response to the host B 2 ADAM 4500 Series User s Manual Appendix B RS 485 Network B 1 Basic Network Layout Multi drop RS 485 implies that there are two main wires in a segment The connected systems tap from these two lines with so called drop cables Thus all connections are parallel and connecting or disconn
138. acteristic of twiIstedpalr cable Figure C 12 The characteristic of the cable The characteristic of the cable Don t strip off too much insulation for soldering This could change the effectiveness of the Shielded Twisted Pair cable and open a path to introduce unwanted noise ADAM 4500 Series User s Manual C 13 Appendix C Grounding Reference System Shielding A difficult way for signal Figure C 13 System Shielding 1 Shield connection 1 If you break into a cable you might get in a hurry to achieve your goal As in all electronic circuits a signal wil use the path of least resis tance If we make a poor connection between these two cables we will make a poor path for the signal The noise will try to find another path for easier flow C 14 ADAM 4500 Series User s Manual Appendix C Grounding System Shieldin a DRM Lal eh veil k m ume Tae ins ie ks at Dar mi 2 A more easy way for signal Figure C 14 System Shielding 2 e Shield connection 2 The previous diagram shows you that the fill soldering just makes an easier way for the signal ADAM 4500 Series User s Manual C 15 Appendix C Grounding Reference C 3 Noise Reduction Techniques isolate noise sources in shielded enclosures e Place sensitive equipment in shielded enclosure and away from computer equipment e Use separate grounds between nois
139. aken from the range 0x8000 to OxBFOO i Offset for use in location of memory taken from the range 0x0000 to OxOFFF Return value The value in memory storage at the indicated address Example include 4500drv h void main void unsigned char sector 32768 unsigned char data unsigned long addr sector num unsigned int i adv printf erase sector Ox80000L n if EraseSector 0x80000L adv printf erase succeed M adv printf Write data 55 to 0x80000 0x80001n data 55 ProgramByte 0x80000L data ProgramByte Ox80000L 1 data ProgramByte Ox80000L 2 data for i 0 i lt 35i adv_printf read d data d n i read_mem 0x8000 0x0000 1 ADAM 4500 Series User s Manual 5 19 j Chapter 5 Programming and Function Library adv printf erase sector Ox80000L n if EraseSector 0x80000L adv printf erase succeed M data 1 for i 0 i lt 32768 i sector i data adv printf Write data 0x01 to Ox80000 0x87FFF n ProgramSector 0x80000 amp sector for i 0 i lt 100 i adv_printf read d data d n i read_mem 0x8000 0x0000 1 Remarks None 5 20 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Get SysMem Set SysMem Syntax unsigned char Get SysMem unsigned char which byte void Set SysMem unsigned char which byte unsigned char data Description Get SysMem Reads a byte from security SRAM Set SysMem Writes a byte to security SRAM Sec
140. al 4 77 Chapter 4 Guidelines for Network Functions UDP CLIENT C include lt stdio h gt include lt stdlib h gt ifdef MSC_VER include lt malloc h gt else include lt mem h gt endif include lt string h gt include lt conio h gt include lt errno h gt include socket h define Errno errno define BufferSize 100 define Host_Port 5510 int main int argc char argv SOCKET SO_4500 struct sockaddr_in Server_addr struct sockaddr_in From_Addr struct hostent he char buf BufferSize int numbytes unsigned int From Size char msg UDP Client Conneted if argc 2 fprintf stderr usage uclient xxx xxx xxx xxxM exit I j if he gethostbyname argv 1 NULL perror gethostbyname exit I j if SO_4500 socket AF_INET SOCK_DGRAM IPPROTO_UDP INVALID_SOCKET perror socket 4 78 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions exit I j Server_addr sin_family AF_INET Server_addr sin_port htons Host_Port Server_addr sin_addr struct in_addr he gt h_addr memset amp Server_addr sin_zero 0 8 if numbytes sendto SO 4500 msg strlen msg O struct sockaddr amp Server addr sizeof struct sockaddr SOCKET_ERROR perror sendto exit I j printf sent d bytes to Yos n numbytes inet ntoa Server addr sin addr From Size sizeof From Addr if numbytes
141. alculates the CRC 16 bit value of the string i ucDataBuf Parameter Description i ucDataBuf The string which you want to calculate CRC code uiLen The length of string i ucDataBuf Return value The CRC16 code Remarks None 5 52 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO Carrier Syntax CHAR SIO Carrier UCHAR i ucPort Description Detects the carrier signal of the specific COM port Parameter Description ucPort The Port number you want to use see remarks Return value If success return TRUE 1 If fail return a non positive number as follows FALSE 0 Illegal Setting 5 Remarks COM COM col2 cOM erent COM3 COM3 cCOM COM J ADAM 4500 Series User s Manual 5 53 Chapter 5 Programming and Function Library SIO ClearBreak SIO SetBreak Syntax CHAR SIO ClearBreak UCHAR i ucPort CHAR SIO SetBreak UCHAHR i ucPort Description SIO ClearBreak Sets the specific COM port to clear BREAK signal SIO SetBreak Sets the specific COM port to send BREAK signal Parameter Description ucPort The Port number you want to use see remarks Return value If success return O If fail return a negative number as follows Illegal Setting 5 Remarks COM COM col2 cOM veer COMB COM3 cCOM COM ei 5 54 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO GetLineStatus SIO SetLinePara
142. ameter None Return value The return value is the ID number of EB5O built in I O board Remarks None 5 14 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Get NodelD Syntax unsigned char Get NodelD void Description Gets the ID number of the ADAM 4500 Series Controller Parameter None Return value The ID number of the ADAM 4500 Series Controller Example include 4500drv h void main void Int I J unsigned char mID found adv printf n Welcome to ADAM4500 PC Based Controller adv printf n Scan I O module adv printf n ADAM4500 NodelD 02Xh Get NodelD Scan ADAM4500 Slot IO Module mID Get BoaralD found 0 if mID EB50_ ID adv_printf n Slot EB50 found 1 j if found 0 adv printf n Slot None installed j Remarks None ADAM 4500 Series User s Manual 5 15 Chapter 5 Programming and Function Library GetRTCtime SetRTCtime Syntax unsigned char GetRTCtime unsigned char Time void SetRTCtime unsigned char Time unsigned char data Description GetRTCtime Reads Real Time Clock chip timer A user can activate a program on the date desired SetRTCtime Sets date and time of the real time clock Parameter Description Time HTC sec the second HTC min the minute HIC hour the hour HTC day the day HTC week day of the week RTC month the month HTC year the year data New contents Return value
143. and data will be checked if the socket option SO OOBINLINE has been enabled see setsockopt The parameter psWritefds identifies those sockets which are to be checked for writability If a socket is connect ing non blocking writability means that the connection establishment successfully completed If the socket is not in the process of connect ing writability means that a send or sendto will complete without blocking The parameter psExceptfds identifies those sockets which are to be checked for the presence of out of band data or any exceptional error conditions Note that out of band data will only be reported in this way if the option SO OOBINLINE is FALSE For a SOCK STREAM the breaking of the connection by the peer or due to KEEPALIVE failure wil be indicated as an exception If a socket is connect ing non blocking failure of the connect attempt is 5 158 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Any of psReadfas psWritefds or psExceptfds may be given as NULL if no descriptors are of interest Four macros are defined in the header file socket 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 16 which may be modified by defining FD SETSIZE to another value before including socket h Internally an fd set is represented as an array of SOCKETs The macros are FD CLR
144. ar far SECTOR DATA Description EraseSector Erases a 64 KB sector of data in the 256 KB Flash memory ProgramByte Programs a byte of information into the 256 KB Flash memory This feature supports data logging or mass information storage ProgramSector Programs an entire 32 KB sector of data of the global variable SECTOR DATA into 256 KB Flash memory Parameter Description ulBase User determined address range to be erased taken from addresses in the range Ox80000L to OxBOOOOL ulAddress User determined destination address for byte transfer taken from the range 0x80000L to OxBFFFFL byte The data user wants to write into the specific byte in the Flash memory ulAddress s User determined destination address in the Flash memory taken from addresses in the range 0x80000L to OxB8000L SECTOR DATA Pointer at the starting address in the origin memory of the user s data array Return value 1 Successful transfer to Flash memory 0 Error destination already occupied excess address range or program error 5 18 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library read mem Syntax unsigned char read mem int memory segment unsigned int i Description Reads far memory data 256 KB Flash memory from Ox80000L to OxBFFFFL where the Absolute Address SEG 16 OFFSET For example 0x800FFL 0x8000 16 OxOOFF Parameter Description memory segment User determined address t
145. argument is incorrect EINVAL The socket is not already bound to an address EISCONN The socket is already connected EMFILE No more file descriptors are available ENETUNREACH The network can t be reached from this host at this time ENOBUFS No buffer space is available The socket cannot be connected ENOTSOCK The descriptor is not a socket ETIMEDOUT Attempt to connect timed out without establishing a connection EWOULDBLOCK The socket is marked as non blocking and the connection cannot be completed immediately It is possible to select the socket while it is connecting by select ing it for writing Remarks This function is used to create a connection to the specified foreign socket address The parameter so 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 psAdaress 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 psAddress 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 See Also accept bind getsockname soc
146. ass atomically through the underlying protocol the error EMSGSIZE is returned and no data is transmitted 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 iIFlags 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 oring any of the following values Value Meaning MSG_DONTROUTE Specifies that the data should not be subject to routing MSG_OOB Send out of band data SOCK_STREAM only See Also recv recvfrom socket sendto 5 162 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library sendto Syntax int sendto SOCKET so const char pcBuf int iLen int iFlags const struct sockaddr psTo int iTolen Description Sends data to a specific destination Parameters Description SO A descriptor identifying
147. ate inside infinite loop X forcalling ADAMTCP ModServer Update periodically if ADAMTCP_ModServer_Update HasMessage check if there is any client message But how do we put the data to the address 40001 40008 for client queries Just simply put any data you want to the physical memory ModbusAddr_Mem 0 0x1234 40001 gt 0x1234 ModbusAddr_Mem 7 0x4321 40008 gt 0x4321 OK we ve learned the techniques of creating a server Now let s see how to make query to get data at 40001 40008 from server First define some needed information for querying server define Server Port 502 502 is the standard port of modbus protocol Zdefine Server IP 10 0 0 1 the IP of server Zdefine iTimeOut 4000 4000 msec for timeout setting Zdefine Read StartAddr 40001 query data start from address 40001 Zdefine Read EndAddr 40008 query data end to address 40008 Zdefine SlavelD 1 5 70 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Second we need to allocate a physical memory for query data unsigned char Resp From Server 16 8 registers from 40001 to 40008 Therefore we need at least a 16 byte physical memory int RespByteCount The total bytes of query data And a descriptor for socket connection is also needed SOCKET SO Finally make a query ADAMTCP Connect amp SO Server IP Server Port ADAMModbusTCP Read amp SO iTimeout SlavelD Read StartAddr Read EndAddr amp
148. ative Answer Host not found WSATRY AGAIN Non Authoritative Host not found or SERVERFAIL WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO_DATA Valid name nodata record of requested type Remarks gethostbyname returns a pointer to a hostent structure as described under gethostbyaddr The contents of this structure correspond to the hostname pszName The pointer which is returned points to a structure which is allocated by SOCKETS The application must never attempt to modify this structure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls A gethostbyname implementation must not resolve IP address strings passed to it Such a request should be treated exactly as if an unknown host name were passed An application with an IP address string to resolve should use inet addr to convert the string to an IP address then gethostbyaddr to obtain the hostent structure See Also 5 182 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library gethostbyadar ADAM 4500 Series User s Manual 5 183 Chapter 5 Programming and Function Library gethostname Syntax int gethostname char pszName int iAddressLen Description Return the standard host name for the local machine Parameters Description pszName A pointer to a buffer that will receive the host name iAddressLen The length of the buffer
149. ble names which is substituted in time with specific values The HTTPD Extension CGI works as follows The extension has to implement one function called the callback function The server has a number of functions that the extension may use e g HttoSendDaita They are designed to give the extension sufficient control over any http request Spawning CGI An external program indicated by the requested URL is spawned All relevant information is passed as environment variables The program gets all input e g posted data from standard in and sends all response through standard out This type of CGI is discouraged in favor of the Extension API The following CGI environment variables are supported CONTENT_TYPE CONTENT LENGTH PATH COMSPEC REQUEST METHOD Enough free memory must be available when Spawning a CGI program or no swapping or overlaying wil be attempted Since COMMAND COM uses al free memory it follows that no CGI program will be spawned if COMMAND COM is the current foreground program ADAM 4500 Series User s Manual 5 191 Chapter 5 Programming and Function Library CGI programs must be small and must execute reasonably quickly While a CGI program is executing the HTTP server is effectively blocked and cannot service any other requests No console input or output should be used A CGI program is invoked by a URL containing a path of cgi bin cgi program where cgi program is the name of an executable pro
150. c 3 2 ADAM 4500 Series User s Manual Chapter 3 Program Download 2 Click on the ADAM 4500 Series Utility to setup ADAM 4500 Series Utility Install Utilities ADAM SOOOTCP 6000 Utility y Ca Install Adam 4500 Series Utility v 1 13 p ADAM 4000 5000 Utility The ADAM 4500 Series Utility offers a graphical interface that helps you configure A the ADAM 4500 Series Controllers This utility C 2001 2500 utility makes ivo conventantt conta iam il the ADAM 4500 Series Controllers 3 Welcome to the ADAM 4500 Series Utility Setup program This program will install ADAM 4500 Series Utility on your computer It is strongly recommended that you exit all Windows programs before running this Setup program Click Cancel to quit Setup and then close any programs you have running Click Next to continue with the Setup program WARNING This program is protected by copyright law and international treaties Unauthorized reproduction or distribution of this program or any portion of it may result in severe civil and criminal penalties and will be prosecuted to the maximum extent possible under law EN ADAM 4500 Series User s Manual 3 3 Chapter 3 Program Download 4 Choose the dictionary path for installing ADAM 4500 Series Utility and then click the Next button r ioi x Advantech ADAM 4500 Series Ula Setup Ve Choose Destination Location Setup will install ADAM 4500 Series Utility in the
151. cDataBits The data bits you want to set up see remarks i ucStopBits The stop bits you want to set up see remarks Return value If success return O If fail return a negative number as follows No Such Port 3 COM wNot Installed 4 Illegal Setting b Remarks econ E NO PARITY 0x00 eaa 0x00 1 Stop Bits ADAM 4500 Series User s Manual 5 41 Chapter 5 Programming and Function Library SIO RecvBytes Syntax INT SIO RecvBytes UCHAR i ucPort UCHAR i ucMode UINT i uinBytes UCHAR o ucDataBuf Description This function call is employed to received string data from the specific COM port On success this function call returns the total bytes has been read from the specific COM port On fail function call returns a negative value as error code Parameter Description ucPort The Port number you want to use see remarks i ucMode Decide to use Block mode or UnBlock mode When using Block mode program will block here until i uinBytes data is received When using UnBlock mode program will not block and return the total number of bytes data have been received directly i uinBytes Number of bytes to be read o ucDataBuf A buffer for received data Return value If success returns the total number of bytes read f fail return a negative number as follows No Such Port 3 Illegal Setting 5 RequestOverQueueSize 6 Remarks COM COM m COM2 COM2 COM3 COM3 COM CcOM4 ELE
152. closesocket remoteSocket sidx 0 printf Release client resource fail 4 66 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions for sidx2 sidx sidx2 lt socketTotal 1 sidx2 if sidx2 lt socketTotal 1 WaitSocketCount sidx2 WaitSocketCount sidx2 1 remoteSocket sidx2 remoteSocket sidx2 1 j else if sidx2 socketTotal 1 WaitSocketCount sidx2 0 remoteSocket sidx2 NULL j socketTotal if timeoutRelease printf Connetion timeout disconnect client dNn sidx else printf Socket error disconnect client Vod n sidx if socketTotal 0 printf Wait for client connect n timeoutRelease FALSE ADAM 4500 Series User s Manual 4 67 Chapter 4 Guidelines for Network Functions ICP CLIENT C Zinclude stdio h include lt stdlib h gt ifdef MSC_VER include lt malloc h gt else include lt mem h gt endif include lt string h gt include lt conio h gt include lt errno h gt include socket h define Errno errno define Server_Port 5510 define MAXDATASIZE 100 int main int argc char argv SOCKET SO 4500 int numbytes 0 char buf MAX DATASIZE struct hostent he struct sockaddr in Server addr char strl str2 str int tmpcount 1 strl TCP n str2 Client n if argc 2 fprintf stderr usage server hostname n exit I j if he gethostbyname argv 1 NULL perr
153. code ADAMTCP Disconnect amp SO 4500 return 0 j else printf Adam 6051 Channel 0 Status for tmp 0 tnp lt DataByteCount tmp printf 2X HostData tmp amp 0x01 j printf j for tmpcnt 0 tmpcnt lt 50000 tmpcnt delay for tmpcnt1 20 tmpcntl 4 tmpcnt1 i return 1 j 4 44 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 6 Modbus RTU Slave Example program DEMORS EXE Source file DEMORS C under ADAM 4500 Series Utility Source Example DemoModbus directory Hardware configuration see figure below LT Download program jx Host PC Programming port ADAM 4500 Series Controller Modbus RTU Slave COM Port Modbus RTU COM port Software application on another PC ex OPC Server Modbus RTU Master This example uses ADAM 4500 Series Controller as Modbus RTU slave and a PC on the same serial network is Modbus RTU master ADAM 4500 Series Controller writes onboard DIO value to address 40001 and Modbus RTU client application such as OPC Server or ADAMVIEW read the value from that address Address O of share memory represents the address 40001 of Modbus address ADAM 4500 Series User s Manual 4 45 Build DEMORS EXE ADAM 4500 Series Chapter 4 Guidelines for Network Functions from DEMORS PRJ under Utility Source Example DemoModbus directory and download DEMORS EXE onto drive D under root directory Put
154. date button to perform the configuration Note 4 II ADAM 4500 Series Utility Ver 1 13 le x File Help Local System ADAM 4500 Series e amp m oe f xum e ua cow x C Program Files Advantect cz EN TAUGIIITHOUU DUCES LUIHIUUr durum E ol M Adam 4500 Series System Conf amp Init C3 WebRoot System Configuration 1 00 AM Ef dhcpstat r IP DHCP E httpget Static IP C DHCP J Obtain DNS address automatically Ef ifstat r T E F ipstat Address 192 fies J Ja Primary DNS EJ MAKEMAIL Gateway 255 255 255 Jo ERISENDMAIL C FTP amp HTTP Configuration ID ID Password Password 8 object s 1175 0 Rights Change Dir Rights J Get Files Creat Del Dir Post Files Write File Use CGI Volume in dr Read File Volume Seria Directory of Update HTTP FTPD EXE br System Initialization 3 fils 6 System Files HTTPFTP Server FTP Server HTTP Server Go z start S Y iii adamasoo LLL Above settings is only an example You have to configure the network settings according to your network environment Click the OK button to finish the network configuration fll ADAM 4500 Series Utility Yer 1 13 18 x File Help Local System ADAM 4500 Series e m e 2 z e as e z eE s sem e um cow z iC Program Files Advantech sae Adam
155. dicating it is still busy and getting more data should be attempted at the next callback Parameter Description iHandle Handle passed in pfsHttpParams pcBuf Far pointer to buffer to receive data iCount Length of buffer Return value gt 0 OK number of bytes received lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF_GETDATA 2 BX iHandle DS SI pcBuf CX iCount Low level return parameters Return code in AX 5 204 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library HttpSendData Syntax int HttpoSendData int Handle char far pcBuf int Count Description The HttpSendData function is used to send data to the client If the return indicates that less than the requested number of bytes has been sent and the extension is busy executing the callback function a O return should be made from the callback indicating it is still busy Then an attempt to send more data should be made at the next callback All the required data should be sent to the client before an HttpSubmitFile functionis used After HttpSubmitFile HttpSendData should not be called again Parameter Description iHandle Handle passed in pfsHttpParams pcBuf Far pointer to buffer with data to send iCount Length of buffer Return value gt 0 Number of bytes actually sent lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF SENDDATA 3 BX iHandle DS
156. ding from and then stop to provide service for sending out the email for ADAM 4500 series 4 30 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions ALARMMAIL C include lt stdio h gt include lt process h gt include lt errno h gt include 4500drv h int SendAlarmMail void int MakeAlarmMail void int count l void main void unsigned long div dov unsigned int tmpcnt if MakeAlarmMail printf make mail fail return j while 1 printf Please input digital output values scanf 9oX amp dov if dov 0x33 return SetDO EB50 ID AllChannels 0 dov printf DO value Ox X press any key to continue n dov getch GetDIO EB50 ID AllChannels 0 amp div if div Ox000f if SendAlarmMail printf send mail error return j j j j ADAM 4500 Series User s Manual 4 31 Chapter 4 Guidelines for Network Functions int MakeAlarmMail void char arg To 1567 9 123 com char arg From f345 hotmail com char arg subject s5510TCP char arg MailContent bmail txt char arg O mail omail dat printf Making Mail n if spawnlp P WAIT d NmailNmakemail exe d NmailNmakemail exe arg To arg From arg subject arg MailContent arg O mail NULL 1 return 0 return 1 j int SendAlarmMail void char argl smtp 123 com char arg2 mail dat
157. e ExampleModbusAppEx 5 110 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Modbus TCP Server Functions ADAMTCP ModServer Create Syntax int ADAMTCP MoasServer Create int Host Port unsigned long waittimeout unsigned int numberConns unsigned char ptr mem int size mem Description Create a Modbus TCP Server Parameters Description Host_Port The port for Modbus TCP server Waittimeout Time out value O OXffffffff milli second NumberConns Maximum connections for client ptr_mem Share memory size_mem The size of share memory Return value 0 No error occurs 91 Invalid socket 92 Error occurs when associates a local socket address with a socket 93 Error occurs when sets up the socket mode 94 Error occurs when listens to the incoming socket Example if err_code ADAMTCP_ModServer_Create 502 5000 20 unsigned char Share_Mem sizeof Share_Mem 0 adv_printf error code is d n err_code adv printf Server started wait for connect n ADAM 4500 Series User s Manual 5 111 Chapter 5 Programming and Function Library ADAMTCP ModServer Update Syntax int ADAMTCP_ModServer_Update void Description Update the Modbus TCP Server The Modbus TCP server needs tobe updated by calling ADAMTCP ModsServer Update function continuously to keep server alive Parameters None Return value 1 New message has come in 0 No new message comes in Example while 1
158. e Packet Driver naming the interface ifO MTU 1500 Receive buffers 5 Route add default ifO router Route all traffic to unknown destinations via if0 using router as a gateway TCP mss 1460 TCP Maximum Segment Size 1460 4 2 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions TCP window 2920 TCP Maximum window 2920 Start prntserv Start printer server on PRN using default port of 10 HOSTS is an optional file containing mappings of IP addresses in dotted decimal notation to names Sample HOSTS file 192 6 1 1 demo 192 6 1 2 router 192 6 1 3 server SOCKET CFG Samples The following configuration file contains the minimum possible commands for a valid configuration file just one This is to specify that the interface should use a Packet Driver the interrupt vector which must be searched for It should use DIX encapsulation have an MTU of 1500 and have a maximum of 5 receive buffers Since no IP address is specified BOOTP will be used and the required operating parameters will be retrieved from a BOOTP server which must be available on the network SOCKET CFG interface pdr ifO dix 1500 5 The following is a more typical example specifying a static IP address a Packet Driver interface a default route the TCP MSS and WINDOW SOCKET CFG Sample configuration file ip address 192 6 1 1 interface pdr ifO dix 1500 5 route add default if0 192 6 1 2 tcp mss 1460 tc
159. e adequate precautions when you touch the equipment 1 8 ADAM 4500 Series User s Manual Chapter 1 System Overview 1 3 8 Dimensions The following diagrams show the dimensions of the system unit and an I O unit All dimensions are in millimeters Figure 1 2 ADAM 4500 Series Controller Dimension ADAM 4500 Series User s Manual 1 9 Chapter 1 System Overview 1 3 9 LED Status There are four LED lights on the ADAM 4500 Series The PWR RUN and COMM LED can be controled using ADAM 4500 Series library LED OFF and LED ON refer to section 5 3 1 BATT LED is the battery status indicator This LED will be on whenever the SRAM backup battery is low 1 3 10 ADAM 4500 Series Controller System Architecture 03 Web Ethernet Modbus TCP fm Ae f Fal ADAM EDUD fs ADAM 4501 las o ADAM 450 aus 1 ADAM 4501 f uu Y i F7 few 7 Communication tw Digital VO ex 7 Angog Wi co ee Controller al oet s i i i R amp 485 Modbus ATU TSF Z i p p E zl ui pag p ADAM Bar Coda ATU Machina Tool Reader ADAM 4000 Modbus Modules Figure 1 3 ADAM 4500 Series Controller System Architecture 1 10 ADAM 4500 Series User s Manual 2 Installation Guidelines Chapter 2 Installation This chapter explains how to install an ADAM 4500 Series Controller A quick hookup scheme is provided that let you easily configure your system before implement it into your application 2 1 System
160. e is answered automatically SIO LowerRaise RTS DTR COM RaiseSignal Signal DTR SIO ModemAutoanswer COM 1 adv printf Now is ready to get data n break Set Break SIO SetBreak COM 1 adv printf Now set a break to modem n n n Wait about 0 3 second retry 30000 for i O i lt retry i d 4 i j SIO ClearBreak COM 1 adv printf Now clear the break n n n break ADAM 4500 Series User s Manual 5 65 case 5 Chapter 5 Programming and Function Library Set DTR line OFF SIO LowerRaise RTS DTR COM LowerSignal Signal DTR Wait about 0 3 second retry 30000 for i O i lt retry i l 5l Check whether DCD is off if com get modem status Ox3F8 amp 0x80 break GO to modem command state SIO ModemHandup COM retry 3 do SIO ModemHandup COM 1 if get modem response buf 1 if buf 0 220 break j adv printf retry ld n 4 retry while retry adv_printf Now is hand up n break 5 66 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Ver COMLib Syntax void Ver COMLib char vstr Description Get COM Port Library version Parameter Description vstr Pointer to array of COM Port Library version information Return value None Example char library ver 20 void main void Ver COMLib library ver adv printf The
161. e of two modes Asa TSR resident program this is the default behavior At this stage unloading of the TSR is not supported De registration is possible by loading the program again This routine may be repeated As a transient program use t command line switch to activate This option will immediately spawn command com From this pro mpt other cgi programs may be loaded The program exits when command com is exited by typing exit at the prompt These programs are 1 cgiecho A very simple program that accepts data from a user and echoes it back nicely formatted Get echoform htm from the browser 2 cgicount A page visit counter Only updates between sessions if transient cgicount t Get num htm from the browser 3 cgiform Does the same as the old fill out the form and submit utility Get caform htm from the browser SSI A very simple SSI implementation that demonstrates the SSI interfaces Template htm is filled by some variables Get ssi htm from the browser The fifth example FFUR Form base File Upload Receiver is only a transient program but can easily be adapted to be similar to the rest It handles the upload of a file as a POST command by filling out ffur htm 5 198 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library HTTPD Function Reference CGIADAP C is an interface program a user may utilize to implement external extention CGI programs This interface
162. e sources and signals e Keep ground signal leads as short as possible e Use Twisted and Shielded signal leads e Ground shields on one end ONLY while the reference grounds are not the same e Check for stability in communication lines e Add another Grounding Bar if necessary e he diameter of power cable must be over 2 0 mmz e Independent grounding is needed for A I A O and communication network while using a jumper box e Use noise reduction filters if necessary TVS etc e You can also refer to FIPS 94 Standard FIPS 94 recommends that the computer system should be placed closer to its power source to eliminate load induced common mode noise Noise Reduction Technigues d X LI agr AC AC Device Device External Signal Power Power Supply Supply Separate Load and Device power Cascade amplify isolation circuit before I O channel Figure C 15 Noise Reduction Techniques C 16 ADAM 4500 Series User s Manual Appendix C Grounding C 4 Check Point List Follow the single point grounding rule Normal mode and common mode voltage Separate the DC and AC ground Reject the noise factor The shield is connected correctly Wire size is correct Soldered connections are good The terminal screw are tight ADAM 4500 Series User s Manual C 17
163. e transfers by usage of wild card characters When getting files with paths or long names no translation of foreign file names is done Specify a valid DOS local file name 2 A short directory list NLST is obtained by Is and the long list with dir 3 Some of the commands can be abbreviated 4 Some commands are aliases added for user comfort like bye exit and quit get and mget and put and mput 5 The optional local file parameter will when specified cause the output of that command to be logged to a file By specifying the file as PRN you can get immediate printouts 6 On some servers you might specify the optional remote file parameter as PRN or the printer output device to do remote printing See also the site nopath command for the SOCKETS FTP server 7 The F3 key and spacebar can be used to recall the last command word by word Below is Aa list of commands recognized by the SOCKETS FTP client some FTP servers might not offer all the facilities ADAM 4500 Series User s Manual 6 5 Chapter 6 Sockets Utility Command abort append ascii binary bye cd directory cwd directory dele file dir file directory local_file exit get remote_file s local_file image Is file directory local_file Icd directory Idir file directory list file directory local_file mget remote_file s local_file mkdir remote_directory mput local_file s remote_file nist file directory local
164. ecting of a node doesn t affect the network as a whole Since ADAM 4500 Series Controller use the RS 485 standard they can connect and communicate with the host PC The basic layouts that can be used for an RS 485 network are Daisychain The last module of a segment is a repeater It is directly connected to the main wires thereby ending the first segment and starting the next segment Up to 32 addressable systems can be daisychained This limitation is a physical one When using more systems per segment the IC driver current rapidly decreases causing communication errors In total the network can hold up to 64 addressable systems The limitation on this number is the two character hexadecimal address code that can address 64 combinations The ADAM converter ADAM repeaters and the host computer are non addressable units and therefore are not included in these numbers Segment 2 Figure B 1 Daisychaining ADAM 4500 Series User s Manual B 3 Appendix B RS 485 Star Layout In this scheme the repeaters are connected to drop down cables from the main wires of the first segment A tree structure is the result This scheme is not recommended when using long lines since it will cause a serious amount of signal distortion due to signal reflections in several line endings RS 485 Repeater N Figure B 2 Star structure Random This is a combination of daisychain and hierarchical structu
165. ed by the MAKEMAIL utility to deliver Logging Format Timestamp Code String Timestamp Weekday Month Day Time Year Code Three digit integer 000 means perfect success 100 199 mean usage error and 200 299 means TCP IP error from server String Human readable explanation of the error code Example SENDMAIL mail datalight com mail dat 6 10 ADAM 4500 Series User s Manual Chapter 6 Sockets Utility XPING XPING starts a continuous string of pings until stopped by a keystroke Syntax XPING ip address interval Remarks ip address This may be a numeric address or a name address Options interval The time to wait between pings in clock ticks Example XPING 10 0 0 1 20 X This will ping the address of 10 0 0 1 every 20 clock ticks ADAM 4500 Series User s Manual 6 11 HTTP and FTP Server Application Chapter 7 HTTP and FTP Server Application HTTP Server Overview he SOCKETS HTTP server HTTPD EXE is a small fast reliable and extendable web server that can run as either an application or TSR Apart from the minimum required file download capability the following additional capabilities are provided 1 Remote Console Server ability to gain terminal type access to the server system using a standard browser without the need to install any software on the browser computer 2 Authentication Both system wide and directory wise 3 CGI Extendibility The ability to extend the server to create dynamic
166. ed div dov char dovi 47 View further code generation options Figure 5 1 Select Advanced code generation Edit Search Hun Compile Project Options Window Help Debug int Sendfalarm int Makefllarm int count void maintvoi lt unsigned char dovi Far Data hreshold EER HEEL Em ul T 127 304 Fi Help Detect and use coprocessor otherwise emulate the 8087780287 Figure 5 2 Select Emulation and 80186 settings 5 1 4 Libraries Sized for Different Memory Modes The ADAM 4500 Series function libraries support four memory models SMALL MEDIUM COMPACT and LARGE You can use library files sized according to your memory model For example if you use small model you can link UTILITYS LIB and LIOS LIB to implement system and low speed I O module access functions On the other hand if you use large model you can link UTILITYL LIB and LIOL LIB 5 4 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Project B File Edit Search Run Compile Debug Application generation int SendAlarmMailtvoid gt Entry Exit Code int MakeAlarmMailtvoid gt C options Advanced options int count 1 Optimizations Source void maintvoid gt Messages lt Hames unsigned div dov char dovi 47 Fi Help Specify how compiler prepares object code memory models etc gt Figure 5 3 Select Code generation Edit Search Run Compile Debug VL ER
167. equested type Remarks This function returns a pointer to a protoent struct ure as described above in getprotobyname The contents of the structure correspond to the given protocol number The pointer which is returned points to a structure which is allocated by SOCKETS The application must never attempt to modify this struct ure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls See Also getprotobyname ADAM 4500 Series User s Manual 5 187 Chapter 5 Programming and Function Library getservbyname Syntax struct servent getservbyname const char pszName const char proto Description Gets service information corresponding to a service name and protocol Parameters Description pszName A pointer to a service name proto An optional pointer to a protocol name If this is NULL getservbyname returns the first service entry for which the pszName matches the s name or one of the s aliases Otherwise getservbyname matches both the pszName and the proto Return Value If no error occurs getservbyname returns a pointer to the servent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO DATA Valid name nodata
168. er FTPD is a file server that can run either as an application or as a T SH The name of the server as displayed in the banner is determined by the HOSTNAME environment variable If the environment variable is not set the name Socket is used The user password file SOCKET UPW in the SOCKETS directory indicated by the SOCKETS environment variable controls access A temporary file is created when a directory listing is requested This file is created in the current directory but can be created in any directory as specified in the FTPDIR environment variable FTPD Program The syntax for FTPD is FTPD options lt ftp_port gt Option Description Ih Display help screen Ir Run server in TSR mode s Display server status u Unload if resident c Close listen m lt MemorySize gt Set memory size n lt MaximumConnections gt Number of simultaneous connections k Abort all active connections and unload Remarks MemorySize The number of bytes of memory available to the server This value defaults to 32768 MaximumConnections The maximum number of simultaneous connections allowed by the server ftp port FTPD will listen on the listed port This parameter defaults to the standard FTP port number of 21 ADAM 4500 Series User s Manual 7 11 Chapter 7 HTTP and FTP Server Application Configuration File FTPD uses the standard SOCKET UPW file for validating logins The file is composed of text lines each represe
169. er BSD Sockets environment like Unix Linux or Windows Winsock a number of issues must be kept in mind The most important one is that ROM DOS is a single user single task single thread operating system The use of blocking calls wil suspend the system until completion which may imply an indefinite time under abnormal or even normal conditions In addition no completion event such as a WSAAsyncSelect windows message for Winsock or a Signal for Unix Linux is available Only applications either using nonblocking operations or the select function may be ported successfully Other applications must be adapted to follow these guidelines Unlike Winsock and like BSD Sockets an error number is returned in the errno variable and is only valid directly after an API call When writing portable code to run on both SAPI and Winsock a simple define can normally be used i e ifdef Windows define Errno WSAGetLastError else define Errno errno endif if Errno WSAEWOULDBLOCK Like in Winsock both the WSAE of Winsock and the E error definitions of BSD may be used eg WSAEWOULDBLOCK and EWOULDBLOCK The actual error numbers are the same as that of Winsock except in cases of DOS error code conflicts eg WSAEINVAL has the same value as the DOS EINVAL Always using the symbolic value and not numeric values will avoid potential ADAM 4500 Series User s Manual 5 119 Chapter 5 Programming and Function Library problems
170. es Utihiy Wer 1 13 Pie rel Lx al brien ix lie Go z z m Pho ar Fer ch De oS Cos Lis Hines see Type FALAR D Y of Fia E laesa c XB ace zd as 5r XB USE fie LESE XB Aptian A Abad PELI XB LBERESFP L 5 obiectis 42500 LEQ don are 16 7 68 Bet saan z MAKKHAIL w ILI ETIIRMIIE ilna ERS 0wt pik DHAIL w amp Sorte E saper um ow Mad ed SEA Pee 1832312 PA i 28 F1 d 13 Fl ite 44 Z6 Fl LIT oe TIEMITIESEDIT TT lad 18 14 39 17 FONE ieput Adam EHSI ogiput 000 Geni SETF eas TET ame ELUHE MAL C wEBROUT AUTORUN BAT Leo pou CPG EXE SOE TP EXE 7 obisha AU LS nnt 95 4 C508 9793 bytes Ine ADAM 4500 Series User s Manual 4 29 Chapter 4 Guidelines for Network Functions 9 Check the mailbox and it should receive the email correctly E inten dicrmafi Ceili j m Mi 3 ADAM 4501 Mall Vest LT Plein Taxi Be BA ger pue Funk xh ete te Fra s urpu heed adnan com bm Berk Wed TII 3 90 MI fe una Cer Sabet AA 45D Mal Test Deer Damas Long bee no me Bert Feli hex AFRE ee PET Note The IP address of ADAM 4500 series should be at the same domain with the IP address of mail server which will help you to send out the email from ADAM 4500 series lf you ask another mail server whose IP address is not at the same domain the mail server will verify the IP address of the email sen
171. esident E Done D NWEBROOT adam Going TSR D NWEBROOT the DO val is 0x22 d start iW ii adam4soo E hetp 10 0 0 1 adam NY 9 53 AM ADAM 4500 Series User s Manual 4 21 Chapter 4 Guidelines for Network Functions ADAM C Zinclude lt stdio h gt include lt io h gt include lt process h gt include lt stdlib h gt include lt string h gt include 4500drv h include CGI Lib h extern unsigned _stklen 3000 extern unsigned heaplen 2000 int far Callback HTTP PARAMS far psParams int returnVal char ptr name char ptr end int count I void main void char homepage name Adam htm if Http Server Reg homepage name return printf Program exiting n HttpDeRegister Adam htm j int far Callback HTTP_PARAMS far psParams limplement your program in this function char buf 200 p ptr val ppass int iQueryLen char Re Htm Content 400 char ptr Re Re Htm Content int numberbytes int DoVal DIVal buf 0 4 22 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions iQueryLen _fstrlen psParams gt szQuery if iQueryLen _fmemcpy buf psParams gt szQuery iQueryLen numberbytes HttpGetData psParams gt iHandle buf iQueryLen 200 iQueryLen if numberbytes lt 0 if numberbytes WOULDBLK return RET_OK else printf wrong input value n j iQueryLen numberbytes ptr
172. essories 7 Advantech Ee Documents gt 7 Advantech Automation 2 nee fj Powerview e Internet Explorer Search gt e Outlook Express WinRAR Q9 Help and Support ir Advantech Adam OPC Server 477 Run an Advantech ADAMView fj Advantech Modbus Ethernet m Log Off Administrator fili Advantech Modbus OPC Server 1 0 gt WP Modbus OPC Server Modbus OPC Server s Help g Turn Off Computer dd OPC Browser Client Pi start Y P 3 Wil Adam4soo Sill Adam4500 S wi 8 05PM Windows XP Embedded 4 Create New Device under Advantech Modbus OPC Server Set Address as 3 according to the configuration in DEMORS C 25 untitled Modbus File Add Edit View Help maja sele 18 x Name Type Location Processing value Description Device Properties i xj Name Device a n Device Type ModBus Word Swap S Comm Port COM2 Address E Timeout fi 000 does not access the physical de Cancel Ready ADAM 4500 Series User s Manual 4 47 Chapter 4 Guidelines for Network Functions 5 Right click on the new device you have just created and choose New Tag 3 untitled Modbus E 81 x Fie Add Edit Yiew Help SA Heel Paste Delete Name Type Location Processing value Description New Group Properties Creates a new Tag Device1 has 0 Tags 6 Configure the Tag Property la xl t U
173. et Files Directory of Creat Del Dir Post Files CONF Write File Use CGI MEHR T Read File AUTORUN BAT AX8796 COM CFGIO EXE SOCKETP EXE REID EXE System Initialization QU wal Iv em Files f HTTPFTP Server FTP Server HTTP Server as start S YW 3 iii adamasoo wm S 6 45PM ADAM 4500 Series User s Manual 3 9 Chapter 3 Program Download 9 Click the Advantech Image Worker button for backup drive D as image file or restore image file to drive D Refer to section 3 7 and 3 8 for more detail fill ADAM 4500 Series Utility er 1 13 File Help la x Local System Se UNO 3072 3074 a Removable Disk s Removable Disk a ADV SRAMDRV IF Control Panel C Shared Documents E Mv Documents A Local Disk CONF Removabl C WwEBROOT Removabl S AUTORUN BAT 1KB Removabl P axe796 COM 13KB System Fol croio exe 35KB File Fold 2H nnc a Foon cuc KB File Fold XI e amp dam 4500 Image Worker Read Image Estimate time 10 minutes File Folder File Folder MS DOS B MS DOS A Application Application Application b Name Size Type modifed 2006 0649 6 02 00 AM 2006 0649 6 02 00 4M 2006 0649 6 02 00 AM 2006 0649 6 02 00 AM 2006 0649 6 02 00 AM 2006 0649 6 03 00 AM 2006 0619 6 03 00 4M 101 8 KB 700 928 byte
174. g function call gets error return this function can get the exact error code for user ADAMTCP ForceMultiCoils ADAMTCP ForceSingleCoil ADAMTCP PresetMultiRegs ADAMTCP PresetSingleReg ADAMTCP_ReadCoilStatus ADAMTCP_ReadHoldingRegs ADAMTCP_ReadInputRegs ADAMTCP_ReadInputStatus Parameters None Return value NULL No error occurs Erro Code Exception error returned Error code 01 ILLEGAL FUNCTION 02 ILLEGAL DATA ADDRESS 03 ILLEGAL DATA VALUE 04 SLAVE DEVICE FAILURE 05 ACKNOWLEDGE 06 SLAVE DEVICE BUSY 07 NEGATIVE ACKNOWLEDGE 08 MEMORY PARITY ERROR 5 90 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Example SOCKET SO 4500 I ADAMTCP ReadCoilStatus amp SO 4500 50 0x01 0x11 0x10 amp DataByteCount HostData lt 0 perror ADAMTCP_ReadCoilStatus n adv printf err code is d n ReturnErr_code ADAMTCP_Disconnect amp SO_ 4500 return 0 ADAM 4500 Series User s Manual 5 91 Chapter 5 Programming and Function Library ADAMTCP Connect Syntax int ADAMTCP_Connect SOCKET SO char Target IP int Target Port Decription Connect to Modbus TCP Server Parameters Description SO A descriptor identifying an unconnected socket Target IP Modbus TCP server IP Target Port Server port for the connection Return value TRUE No error occurs 1 Error occurs when gets the host name 2 The socket is invalid when initializes the socket 3 Error
175. gle letter privilege code set if he has privilege to use the Remote Console The code should be missing if that user does not have Remote Console privilege An additional authentication feature is implemented htaccess This feature provides a per directory permission override mechanism It is enabled using t as command line switch If htaccess is enabled the default mechanism may be skipped but no default users or remote console access will be available A fie called HTACCESS typically hidden contains authentication overrides to enable partial anonymous access or additional password security to subdirectories etc If this feature is activated the server code will look for HTACCESS files in each directory starting from the requested path and continuing upward in the directory structure assuming the root directory to be at the top until an HTACCESS file is found lf no file is found then the default settings are used An anonymous access entry is available for the developer to specify that some subdirectory is authorized for any user although its parent directory is password protected CGI scripts can also be controlled via the HTACCESS mechanism 7 6 ADAM 4500 Series User s Manual HTTPD Program The syntax for HTTPD is HTTPD options http port lt rc_port gt Any combination of these switches may be used They should be separated by at least one space Option h t s it u Ic d Ig p
176. gram which must be in the HTTP root directory or in the path Note that the cgi bin part is stripped off and does not represent a real directory lt Cgi program gt may be followed by a and a command line On entry to the CGI program the environment variables listed above are set up and can be accessed If a command line is given it can also be accessed in the normal way The CGI program generates a dynamic page by writing to STDOUT When the CGI program terminates this output is sent to the remote client browser The output can consist of a header and a body part separated by an empty line If the header contains a Content type line the content type will be set to that type and only the body will be sent to the client Otherwise all the output will be sent to the client using content type text plain COMMAND COM can be invoked as a CGI program to perform simple DOS functions e g directory listings The following example performs a directory listing http www embedded server com cgi bin command cdir The next one performs a wide directory listing using a wild card specification http www embedded server com cgi bin command cdir 20 htm 20 w Note the use of 9620 to specify a space character Refer to the INDEX HTM web page for an example of various ways of calling CGI programs The NUM EXE program with source code NUM C demonstrates the use of a header and body part building a simple page visited web page
177. gramming and Function Library SO SNDBUF In Specify buffer size for sends TCP NODELAY BOOL Disables the Nagle algorithm for send coalescing 5 172 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library BSD options not supported for setsockopt are Value Type Meaning SO ACCEPTCONN BOOL Socket is listening SO ERROR Int Get error status and clear SO RCVLOWAT Int Receive low water mark SO ROVTIMEO Int Receive timeout SO_SNDLOWAT Int Send low water mark SO_SNDTIMEO Int Send timeout SO_TYPE Int Type of the socket IP_ OPTIONS Set options field in IP header See Also bind getsockopt ioctlsocket socket ADAM 4500 Series User s Manual 5 173 Chapter 5 Programming and Function Library shutdown Syntax int shutdown SOCKET so int how Description Disables sends and or receives on a socket Parameters Description SO A descriptor identifying a socket how A flag that describes what types of operation will no longer be allowed Return Value If no error occurs shutdown returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EINVAL how is not valid ENOTCONN _ The socket is not connected SOCK STREAM only ENOTSOCK The descriptor is not a socket Remarks shutdown is used on all types of sockets to disable reception transmission or both
178. he Nagle algorithm The Nagle algorithm is used to reduce the number of small packets sent by a host by buffering unacknowledged send data until a full size packet can be sent However for some applications this algorithm can impede performance and TCP NODELAY may be used to turn it off Application writers should not set TCP_NODELAY unless the impact of doing so is well understood and desired since setting TCP NODELAY can have a significant negative impact of network performance TCP NODELAY is the only supported socket option which uses eve IPPROTO_TCP all other options use level SOL SOCKET The following options are supported for setsockopt The Type identifies the type of data addressed by optval Value Type Meaning SO BROADCAST BOOL Allow transmission of broadcast messages on the socket SO DEBUG BOOL Record debugging information SO DONTLINGER BOOL Don t block close waiting for unsent data to be sent Setting this option is equivalent to setting SO LINGER with onoff set to zero SO DONTROUTE BOOL Don t route send directly to interface SO KEEPALIVE BOOL Send keepalives SO LINGER struct linger Linger on close if unsent data is present SO OOBINLINE BOOL Heceive out of band data in the normal data stream SO RCVBUF Int Specify buffer size for receives SO REUSEADDR BOOL Allow the socket to be bound to an address which is already in use See bind ADAM 4500 Series User s Manual 5 171 Chapter 5 Pro
179. he 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 recvfrom on a Socket after shutdown has been invoked with how set to 0 or 2 EWOULDBLOCK The socket is marked as non blocking ADAM 4500 Series User s Manual 5 153 Chapter 5 Programming and Function Library and the recvfrom operation would block 5 154 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library EMSGSIZE The datagram was too large to fit into the specified buffer and was truncated ECONNABORTED The virtual circuit was aborted due to timeout or other failure ECONNRESET The virtual circuit was reset by the remote side Remarks 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 If the socket has been configured for in line reception of out of band data socket option SO OOBINLINE and out of band data is unread only out of band data will be returned The application may use the ioctlsocket SIOCATMARK to determine whether any more out of band data remains to be read The psFrom and piFromlen parameters are ignored for SOCK STREAM sockets For datagram sockets data is extracted from the first enqueued datagram
180. he same as the total amount of data queued on the socket If so is of type SOCK DGRAM FIONREAD returns the size of the first datagram queued on the socket SIOCATMARK Determine whether or not all out of band data has been read This applies only to a socket of type SOCK STREAM which has been configured for in line reception of any out of band data SO_OOBINLINE If no out of band data is waiting to be read the operation returns TRUE Otherwise it returns FALSE and the next recv or recvfrom performed on the socket will retrieve some or all of the data preceding the mark the application should use the SIOCATMARK operation to determine whether any remains If there is any normal data preceding the urgent out of band data it will be received in order Note that a recv or recvfrom will never mix out of band and normal data in the same call argp points at a BOOL in which ioctlsocket stores the result Compatibility This function is a subset of ioctl as used in Berkeley sockets ln particular there is no command which is equivalent to FIOASYNC while SIOCATMARK is the only socketlevel command which is supported See Also socket setsockopt getsockopt ADAM 4500 Series User s Manual 5 145 Chapter 5 Programming and Function Library listen Syntax int listen SOCKET so int Backlog Description Establishes a socket to listen for incoming connection Parameters Description SO A descriptor
181. he server will record network events but only handle them once it is triggered by a CGI user Server Memory The server s memory usage may be controlled in two ways 1 By specifying the amount of memory when going TSR 2 By specifying the maximum number of connections the server will allow Option 1 is the recommended option Use Option 2 if you have heavy web pages usually the type where pages consist of frames and many images etc Connections are generally reset when more connections are attempted than the defined maximum The client then must retry to establish the lost connections leading to a more distributed load on the server Spawning CGI An external program indicated by the requested URL is spawned All relevant information is passed as environment variables The CGI program gets all input e g posted data from standard in and sends all response through standard out Spawning CGI is discouraged in favor of Extension CGI For more information please see the ROM DOS Developer s Guide section CGI Application API ADAM 4500 Series User s Manual 7 5 Chapter 7 HTTP and FTP Server Application Authentication Default authentication matches the capabilities of the FTP server as documented in the section FTP Server on page 217 A file called SOCKET UPW should exist in the SOCKETS environment variable directory The default permission file controls remote console access Each listed user has a sin
182. hes the s port Otherwise getservbyport matches both the port and the proto Return Value If no error occurs getservbyport returns a pointer to the servent structure described above Otherwise it returns a NULL pointer and a specific error number is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed WSANO RECOVERY Non recoverable errors FORMERR REFUSED NOTIMP WSANO DATA Valid name nodata record of requested type Remarks getservbyport returns a pointer a servent structure as described above for getservbyname The pointer which is returned points to a structure which is allocated by SOCKETS The application must never attempt to modify this structure or to free any of its components The application should copy any information which it needs before issuing any other SOCKETS API calls See Also getservbyname 5 190 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 3 7 HTTP Functions CGI LIB LIB CGI Application API Server API Introduction The SOCKETS web servers HTTPD EXE and HTTPFTPD EXE provide both a Spawning Common Gateway Interface CGI and an Extention API with the ability to extend the server to create dynamic web pages perform specialized tasks etc One of the extentions provided is a Server Side Includes SSI interface using the CGI interface enabling a user to create web pages using HTML templates with varia
183. ication FTPD EXE 45KB Application 2006 07 04 9 03 00 AM KB Application 2t 7 HrTPFTPD EXE B3KB Application 2006 07 04 9 02 00 4M lt B Application 2t 50KB Application 2t OKE Application 2t KB Application 2t j HTML Do X E 7 object s 287 3 KB 2 object s 107 1 KB 706 048 bytes free Unknown host O Hostname 10 0 0 1 ie 10 0 0 1 Net mask 255 0 0 0 D gt cd webroot D NWEBROOT ftpd r Sockets FIP Server v6 22 Revision 4 11 1525 Copyright c 1989 2003 Datalight Inc Portions copyright c GPvNO 2004 compiled 0471372004 Going resident D WEBROOT A start S y amp ET Adam4500 ww 9 42 AM 3 Connect to the FTP server on Host PC The IP Address of Host PC and ADAM 4500 Series Controller should be in the same domain m D L end fF Type the name of a program Folder document or an I Internet resource and Windows will open it For you Open tp 10 0 0 1 Cancel Browse resp esee A d 3 2 diii Adam4so0 Fer Chapter 4 Guidelines for Network Functions 4 Login FTP server by typing user name and related password user names and passwords are listed in SOCKET UPW under ADAM 4500 Series Utility Source Drive_D Default_files Conf B ftp 10 0 0 1 Microsoft Internet Explorer File Edit View Favorites Tools Help a7 Qe M z a pP Search Folders lay S gt d ie Ess Addess amp 1tp o o01 gE CE ij x W gt Either the server
184. ication of ECONNREFUSED ADAM 4500 Series User s Manual 5 147 Chapter 5 Programming and Function Library Compatibility iBacklog is limited silently to 5 As in 4 3BSD illegal values less than 1 or greater than 5 are replaced by the nearest legal value See Also accept connect socket 5 148 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ntohl Syntax u long ntohl u long ulNetlong Description Converts a u_long from network to host byte order Parameters Description ulNetlong A 32 bit number in network byte order Return Value ntohl returns the value in host byte order Remarks This routine takes a 32 bit number in network byte order and returns a 32 bit number in host byte order See Also htonl htons ntohs ADAM 4500 Series User s Manual 5 149 Chapter 5 Programming and Function Library ntohs Syntax u short ntohs u short usNetshort Description Converts au short from network to host byte order Return Value ntohs returns the value in host byte order Parameters Description usNetshort A 16 bit number in network byte order Remarks This routine takes a 16 bit number in network byte order and returns a 16 bit number in host byte order See Also htonl htons ntohl 5 150 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library recv Syntax int recv SOCKET so char pcbuf int iLen int iFlags Descr
185. identifying a bound unconnected socket iBacklog The maximum length to which the queue of pending connections may grow Return Value If no error occurs listen returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EADDRINUSE An attempt has been made to listen on an address in use EINVAL The socket has not been bound with bind or is already connected EISCONN The socket is already connected EMFILE No more file descriptors are available ENOBUFS No buffer space is available ENOTSOCK The descriptor is not a socket EOPNOTSUPP The referenced socket is not of a type that supports the listen operation Remarks 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 so is put into passive mode where incoming connections are acknowledged and queued pending acceptance by the process This function is typically used by servers that could have more than one connection request at a time if a connection request arrives with the queue full the client will receive an error with an 5 146 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ind
186. igned char Share Mem sizeof Share Mem printf err code is Yod n Error_Code return printf server started n wh le 1 disable GetDIO EB50_ID AllChannels 0 amp div 4 50 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions Share Mem 0 div write DIO status to modbus address 40001 enable for tmpcnt 0 tmpcnt 50000 tmpcnt delay for tmpcntl 0 tmpcntl lt 8 tmpcntl 4 4 ADAM 4500 Series User s Manual 4 51 Chapter 4 Guidelines for Network Functions 4 7 Modbus RTU Master Example program DEMORC EXE Source file DEMORC C under ADAM 4500 Series Utility Source Example DemoModbus directory Hardware configuration see figure below Downloafi program ADAM 4500 Series Controller Modbus RTU Master ADAM 4056S RS 485 DIO module Modbus RTU Slave This example uses ADAM 4500 Series Controller as Modbus RTU master to connect to the ADAM 4056S support Modbus RTU protocol and can be a Modbus RTU slave here and the DIO value of ADAM 4056S module can be controlled by ADAM 4500 Series 4 52 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions Controller through Modbus RTU communication ADAM 4500 Series User s Manual 4 53 Chapter 4 Guidelines for Network Functions 1 Build DEMORC EXE ADAM 4500 Series Utility Source Example DemoModbus directory and download DEMORC EXE onto drive D
187. il Additional recipients are specified by repeated use of the t parameter If the ToAddress is a name that can be resolved by either the DNS server or host file then the servername is not necessary FromAdaress Used to identify the sender of the message Subject The subject line of the e mail message BodyTextFile The local file containing the body text of the e mail message to deliver OutputFile The local file name in which to store the prepared file for delivery by SENDMAIL This file is overwritten if it already exists Attachment The name of a local file to be binary attached to this e mail message Multiple attachments are created by repeated use of the a parameter Files are attached as MIME parts encoded with the application x uuencode content type Example MAKEMAIL tfred yahoo com fmary yahoo com sStatus bmessage txt omail dat MAKEMAIL tfred tbarney fwilma sDinner obmenu txt omail dat MAKEMAIL tfred fwilma sBowling bbody txt aStone pg aRock jpg omail dat ADAM 4500 Series User s Manual 6 9 Chapter 6 Sockets Utility SENDMAIL SENDMAIL delivers e mail messages packaged by the MAKEMAIL application to an Internet mail server SENDMAIL also creates a local log file to indicate successful send or failures Syntax SENDMAIL server file Options Server The IP address or DNS name of the Internet mail server to receive the message File The file creat
188. ion will also be ignored and ioctlsocket with the SIOCATMARK command will always return an argument value of 1 Error Reporting In general the C functions implementing the SOCKETS API return a value of SOCKET ERROR if the return type is int and an error is encountered in which case the actual error code is returned in a common variable errno ERR HE ENTRY is returned when the SOCKETS kernel has been interrupted This condition can occur only when the API is called from an interrupt service routine Programs designed for this type of operation such as TSR programs activated by a real time clock interrupt should be coded to handle this error by re trying the function at a later stage Other sources of Information Many good books have been written on the Sockets API Pocket Guide to TCP IP Sockets C Version by Michael J Donahoo Kenneth L Calvert Windows Sockets Network Programming Addison Wesley Advanced Windows Series by Bob Quinn et al Hardcover Internetworking with TCP IP Vol lll Client Server Programming ADAM 4500 Series User s Manual 5 117 Chapter 5 Programming and Function Library and Applications Windows Sockets Version by Douglas E Comer David L Stevens Contributor Hardcover 5 118 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library The Winsock 1 1 help file WINSOCK HLP is also a very useful source of information Porting Issues When porting an application from anoth
189. ions Here are two example configuration files by the following demonstrations SOCKET CFG Packet driver settings ip address 192 166 1 4 interface pdr if0 dix 1500 10 0x60 which are used The following will cause SOCKETS to display IP status ip address The following lines set TCP parameters ip ttl 64 tcp mss 1460 tcp window 2920 SOCKET UPW su su drwcepgm su can do everything on whole system Nouest rg everyone can read FTP and get HTTP from HTTP_DIR guest testl testl drep testl can change directories and read files FTP testl get and post files HTTP in HTTP_DIR ftp ftpl guest rd ftpl can read files and change directories FTP in YHTTP_DIR guest ftpl has no HTTP rights httpl httpl epgm httpl can get and post files use CGI and use remote console httpl has no FTP rights userl userl user userl rdcw Z userl has full FTP access rights to the directory Y7HTTP_DIR user user1 userl has no HTTP rights ADAM 4500 Series User s Manual 4 5 Chapter 4 Guidelines for Network Functions 4 1 FTP Server Utility FTPD EXE System configuration Running FTP server on ADAM 4500 Series Controller FTP Client program on host PC 1 Download FTPD EXE under ADAM 4500 Series Utility Source Drive DExtension files on Host PC onto drive D under Webroot directory Put switch into Initial mode ADAM S00 Series Litility Wer 113 s ler xj
190. iption Heceives data from a socket Parameters Description SO A descriptor identifying a connected socket pcBuf A buffer for the incoming data iLen The length of pcBuf iFlags opecifies the way in which the call is made Return Value If no error occurs recv returns the number of bytes received If the connection has value of been closed it returns 0 Otherwise a SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN ENOTCONN ENOTSOCK EOPNOTSUPP IS ESHUTDOWN EWOULDBLOCK EMSGSIZE EINVAL ECONNABORTED ECONNRESET SOCKETS has detected that the network subsystem has failed The socket is not connected The descriptor is not a socket MSG_OOB was specified but the socket 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 The datagram was too large to fit into the specified buffer and was truncated The socket has not been bound with bind The virtual circuit was aborted due to timeout or other failure The virtual circuit was reset by the remote side ADAM 4500 Series User s Manual 5 151 Chapter 5 Programming and Function Library Remarks This function is used on connected datagram or stream sockets specified by the so parameter and is used to read incoming dat
191. irst four examples may operate in one of two modes As a TSR resident program this is the default behavior At this stage unloading of the TSR is not supported De registration is possible by loading the program again This routine may be repeated As a transient program use f command line switch to activate This option will immediately spawn command com From this prompt other cgi programs may be loaded The program exits when command com is exited by typing exit at the prompt These programs are 1 cgiecho A very simple program that accepts data from a user and echoes it back nicely formatted Get echoform htm from the browser 7 4 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Application 2 cgicount A page visit counter Only updates between sessions if transient cgicount t Get num htm from the browser 3 cgiform Does the same as the old fill out the form and submit utility Get caform htm from the browser 4 SSI A very simple SSI implementation demonstrating the SSI interfaces Template htm is filled by some variables Get ssi htm from the browser The fifth example FFUR Form base File Upload Receiver is only a transient program but can easily be adapted to be similar to the rest It handles the upload of a file as a POST command by filling out ffur htm Passive Mode The server may be run in passive mode by specifying a p command line switch When passive t
192. is section provides basic information on wiring the power supply I O units communication port connection and programming port connection 2 39 1 Power Supply Wiring Although the ADAM 4500 Series Controller is designed for using a standard industrial unregulated 24 V DC power supply they accept any power unit that supplies within the range of 10 to 30 VDC The power supply ripple must be limited to 200 mV peak to peak and the immediate ripple voltage should be maintained between 10 and 30 Vpc Screw terminals Vs and GND are for power supply wiring and the wires used should be sized at least 2 mm Power Supply 10V ta 30Vpc Figure 2 5 ADAM 4500 Series Controller power wiring ADAM 4500 Series User s Manual 2 5 Chapter 2 Installation 2 3 2 I O modules wiring The system uses a plug in screw terminal block for the interface between I O modules and field devices The following information must be considered 1 The terminal block accepts wires from 0 5 mm to 2 5 mm 2 Always use a continuous length of wire Do not combine wires to make them longer 3 Use the shortest possible wire length 4 Use wire trays for routing where possible 5 Avoid running wires near high energy wiring 6 Avoid running input wiring in close proximity to output wiring where possible The figures below show how to connect external signals to I O connector of ADAM 4500 Series Controller 2 3 1 1 ADAM 4501 4501D SSSSSSs
193. iseSignal 0x01 LowerSignal 0x02 l l Signal RTS 0x01 RTS signal Luesignal Signal DTR 0x02 DTR signal 5 56 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO Modemlnitial Syntax CHAR SIO_Modemlnitial UCHAR i ucPort Description Sets modem to initial status Due to the ADAM 4500 Series system s construction the modem can only be connected to COM1 This function resets the modem to the initial state The command has the same effect as sending the ASCII command atz to the modem Parameter Description ucPort The Port number you want to use see remarks Return value If success return O If fail return a negative number as follows Illegal Setting 5 Remarks COMI COM1 ADAM 4500 Series User s Manual 5 57 Chapter 5 Programming and Function Library SIO ModemAutoanswer Syntax CHAR SIO ModemAutoanswer UCHAH i ucPort Description Sets up modem to auto answer phone calls Parameter Description ucPort The Port number you want to use see remarks Return value If success return O If fail return a negative number as follows Illegal Setting b Remarks COM COM 5 58 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO ModemCommand Syntax CHAR SIO ModemCommand UCHAR i ucPort UCHAR i ucCmd otr Description Sends an AT command string to the modem For details refer to the AT command document provided by the manufac
194. ith valid address in the range of 40001 40008 Before starting to create a server we need to define the slave ID for server define SlavelD 1 5 68 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library And second we need to allocate a physical memory for address 40001 4008 int ModbusAddr_Mem 8 ModbusAddr_Mem 0 gt 40001 ModbusAddr Mem 7 2 40008 Finally we can create a server The COM and Slave are used to specify that the COM1 is used as slave mode and dedicated for server use Modbus COM Init COM 1 Slave unsigned long 9600 NO PARITY DATAG STOP1 ADAMRTU ModServer Create SlavelD unsigned char ModbusAdadr Mem sizeof ModbusAddr_Mem But how do we put the data to the address 40001 40008 for client queries Just simply put any data you want to the physical memory ModbusAddr_Mem 0 0x1234 40001 gt 0x1234 ModbusAddr_Mem 7 0x4321 40008 gt 0x4321 OK we ve learned the techniques of creating a server Now let s see how to make query to get data at 40001 40008 from server First define some needed information for querying server Zdefine Read StartAddr 40001 query data start from address 40001 Zdefine Read EndAddr 40008 query data end to address 40008 Zdefine SlavelD 1 Second we need to allocate a physical memory for query data unsigned char Resp From Server 16 8 registers from 40001 to 40008 Therefore we need at least a 16 byte physical memory int
195. itialization DHCPSTAT EXE p onn 7 HTTPFTP Server FTP Server HTTPSeve co 8 fil us zi start S YW mi Adam4500 mS 7 19PM 4 There will be window showing Warning click Yes to initialize drive D Please note that drive D will be formatted and all the files on drive D will be lost If you would like to backup the drive contents please refer to section 3 7 la x ADAM 4500 Series a wem Alafon z rogram Elosiidvanten Adam 4500 Series Configuration l i Name m Adam 4500 Series System Conf amp Init O webRoot M System Configuration Ef dhcpstat IP DHCP httpaet StaticIP C DHCP Obtain DNS address automatically istat Address Primary DNS ips E MAKEMAIL Gateway EIE Warina KK 0 xe r FTP amp HTTP Con WARNING WARNING EE This action will format the D drive on ADAM 4500 E 4ll the data on that drive will be erased ID Are you sure Password I 02 00 AM 02 00 AM 02 00 AM 02 00 AM 02 00 AM 04 00 AM 0 3 00 AM 0 3 00 AM Rights B object s a Creat Del Dir Post Files Write File Use CGI Read File Update REID EXE system Initialization AQUIS EE 6 System Files JW HTTPFTP Server FTP Server HTTP Server zi start S Y ii adamasoo MMS 7 20PM 3 12 ADAM 4500 Series User s Man
196. kETP ExE 48KB Application 1980 01 01 12 00 00 PM DemoTS c 2KB CFI E DEMOTS DSK 3KB DSK DEMOTS EXE 51KB Appl DEMOTS OBJ 2KB OBJ E DemoTS PRJ 5KB PRAJ 29KB HFi gt 17 object s 230 0 KB object s 142 4 KB 702 976 bytes free 01 01 1980 01 01 1980 01 01 1980 01 01 1980 SAS sass 702 976 bytes D gt DEMOTC 10 0 0 2 Starting to send Adam 6051 Channel O Status 1 Adam 6051 Channel O Status 1 4 42 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions DEMOTC C Zinclude mod h Zdefine Server Port 502 Zdefine MAXDATASIZE 100 int main int argc char argv char ServerIP SOCKET SO 4500 unsigned char HostDatalMAXDATASIZE int DataByteCount 0 int tmp unsigned int tmpcnt 0 tmpcnt1 0 int errcode memset HostData MAXDATASIZE 0 if argc 2 ServerIP argv 1 j else printf Please input Server IP n return 0 j if ADAMTCP_Connect amp SO_4500 ServerIP Server_Port lt 0 perror ADAMTCP_Connect n ADAMTCP Disconnect amp SO 4500 return 0 j printf Starting to send n wh le 1 Query Adam 6051 Server if errcode ADAMTCP_ReadCoilStatus amp SO 4500 50 0x01 0x01 Ox01 amp DataByteCount HostData 0 ADAM 4500 Series User s Manual 4 43 Chapter 4 Guidelines for Network Functions if errcode TCPTimeOut_Err perror Time Out n else printf Error Error Code is d n err
197. ket and select 5 130 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library getpeername Syntax int getpeername SOCKET so struct sockaddr psAddress int piAddressLen Description Gets the socket address of the peer to which a socket is connected Parameters Description SoA descriptor identifying a connected socket psAddress The structure which is to receive the socket address of the peer piAddressLen A pointer to the size of the psAdaress structure Return Value If no error occurs getpeername returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EFAULT The piAddressLen argument is not large enough ENOTCONN The socket is not connected ENOTSOCK The descriptor is not a socket Remarks getpeername retrieves the socket address of the peer connected to the socket so and stores it in the struct sockaddr identified by psAadress lt is used on a connected datagram or stream socket On return the p AddressLen argument contains the actual size of the socket address returned in bytes See Also bind socket getsockname ADAM 4500 Series User s Manual 5 131 Chapter 5 Programming and Function Library getsockname Syntax int getsockname SOCKET so struct sockaddr psAddress int p AddressLen Description Gets the local soc
198. ket address for a socket Parameters Description SO A descriptor identifying a bound socket psAddress Receives the socket address name of the socket piAddressLen A pointer to the size of the psAddress buffer Return Value If no error occurs getsockname returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EFAULT The piAddressLen argument is not large enough ENOTSOCK The descriptor is not a socket EINVAL The socket has not been bound to an address with bind Remarks getsockname retrieves the current socket address for the specified socket descriptor in psAddress lt is used on a bound and or connected socket specified by the so parameter The local association is returned This call is especially useful when a connect call has been made without doing a bind first this call provides the only means by which you can determine the local association which has been set by the system 5 132 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library On return the piAddressLen argument contains the actual size of the socket address returned in bytes lf a socket was bound to INADDR ANY indicating that any of the host s IP addresses should be used for the socket getsockname wvill not necessarily return information about the host IP address unless the
199. l n adv printf 3 Set to auto answer M adv printf 4 Set BREAK Mn adv printf 5 Hand up n adv printf n Please select a item to implement n c getch switch c case 0 return case 1 Install the interrupt service routine for COM 1 i SIO Open COM 1 20 printf error n return j if SIO_SetState COM1 unsigned long 9600 NO PARITY DATA8 STOP1 20 printf Set State Error n return Show the data format on the screen adv printf COM port is COM1 baud rate is 9600 bps data format is N 8 1 r n break case 2 Send prefix SIO_ModemCommand COM1 AT Wait about 1 second retry 100000 for i 0 i lt retry i b I 4 i j 5 64 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library case 3 case 4 Clear the buffers of the transmitter and receiver SIO_PurgeBuf COM1 Clear RXBuffer SIO_PurgeBuf COM1 Clear TXBuffer Start to dial Set DTR is ON 1 SIO LowerRaise RTS DTR COM RaiseSignal Signal DTR Send the dialing command and phone number sprintf buf 886222184867 SIO_ModemDial COM1 buf adv printf Command s n buf Wait for the response from the other end if get modem response buf 1 adv printf Response s n buf else adv printf Response s n No response break After one ring bell the phon
200. l completion the ioctlsocket returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EINVAL ICmd is not a valid command or pulArgp is not an acceptable parameter for Cmd or the command is not applicable to the type of socket supplied ENOTSOCK The descriptor so is not a socket Remarks 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 so pulArgo points at 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 disabled This is consistent ADAM 4500 Series User s Manual 5 143 Chapter 5 Programming and Function Library with BSD sockets 5 144 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library FIONREAD Determine the amount of data which can be read atomically from socket so pulArgp points at an unsigned long in which ioctlsocket stores the result If SO is of type SOCK STREAM FIONREAD returns the total amount of data which may be read in a single recv this is normally t
201. le Edit View yorites Tools Help a Q Bak GQ T B 75 J Search Se Favorites OIZ A 15 r3 Address PLUIE m Go Links F D WebRoot webadam htm User name i httpi X Password eeeee E Opening page http 10 0 0 1 webadam htm Internet A start S W EJ ilb Adam4soo IE http 10 0 0 1 index mi 10 36 AM 7 You can set the status for ADAM 4500 Series Controller built in I O board EB50 by IE and then click the Submit button EI http 10 0 0 1 webadam htm Microsoft Internet Explorer 5 Xl File Edit view Favorites Tools Help a Rp Back gt M B A 7 Search Se Favorites 2 b Address http 10 0 0 1 webadam htm X Go Links Please enter Adam EB50 status in hexadecimal format and click Submit edam E Doe aus 2 4 20 A E E Done POP Po agp internet A start S W EJ Ail Adam4soo amp 3 http 10 0 0 1 weba wm 9 52 aM Chapter 4 Guidelines for Network Functions 8 Then you can see if the EB50 status is correctly updated in EE 14900 Series Controller Utility Local Suster I amp N amp M ABNN Series Zn 3 http 10 0 0 1 Adam htm Microsoft Internet Explorer 0 x C Program Files Advantechi File Edit view Favorites Tools Help A 5 S Back x i2 amp p Search yv Favorites 64 T Address http 10 0 0 1 Adam htm JE E Go Links Going r
202. led features include built in HTTP Server FTP Server and E mail functions The modularized I O design provides high flexibility for versatile application requirements ADAM 4500 Series Controller also supports rich Modbus function libraries including Modbus RTU Master and Slave and Modbus TCP Server and Client function libraries The ADAM 4500 Series Controller includes following models ADAM 4501 Ethernet Enabled Communication Controller with 8 DI O ADAM 4501D Ethernet Enabled Communication Controller with 8 DI O and LED Display 1 2 ADAM 4500 Series User s Manual Chapter 1 System Overview 1 2 Features The system of ADAM 4500 Series Controller consists of two major components the main unit and I O modules The main unit includes the communication ports CPU and so on The I O Module of ADAM 4501 4501D includes the 8 digital I O channels Besides the ADAM 4501D also includes 7 segment display to show needed information 1 2 1 Control flexibility with C programming The ADAM 4500 Series Controller includes an 80188 CPU and a built in ROM DOS operating system It can be used in a way similar to how one uses an x86 PC in the office Programmers in C can write and compile applications in Borland C 3 0 and download to the ADAM 4500 Series Controller Given the prevalence of C language programming tools this is a distinct advantage for many users and can result in a very short learning curve and very modest training ex
203. left to right Internet Addresses Values specified using the notation take one of the following forms ab cd a b c ab a 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 ADAM 4500 Series User s Manual 5 139 Chapter 5 Programming and Function Library else on the Internet In the interests of compatibility with their software they are supported as specified 5 140 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library When a three part address is specified the last part is interpreted as a 16 bit quantity and placed in the right most two bytes of the network address This makes the three part address format convenient for specifying Class B network addresses as 128 net host When a two part address is specified the last part is interpreted as a 24 bit quantity and placed in the right most three bytes of the network address This makes the two part address format convenient for specifying Class A network addresses as net host When only one part is given the value is stored directly in the network address without any
204. ls are listed in the following table 5 2 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Function Sub function Task 07h 186 or greater cd processor esc instruct 10h Oeh TTY Clear output 11h Get equipment 12h Get memory size 15h 87h Extended memory read 88h Extended memory size cOh PS 2 or AT style A20 Gate table 16h 0 Read TTY char 1 Get TTY status 2 Get TTY flags 18h Print Failed to BOOT ROM DOS message 19h Reboot system 1ah 0 Get tick count 1 Set tick count 2 Get real time clock 3 Set real time clock 4 Get data 5 Set data 1ch Timer tick Table 5 1 ADAM 4500 Series Controller mini BIOS function calls 5 1 3 Converting program codes The ADAM 4500 Series Controller has an 80188 CPU Therefore programs downloaded into its flash ROM must be converted into 80186 or 80188 compatible codes firstly and the floating point operation must be set to Emulation Mode For example if you develop the application program in Borland C you will compile the program as following picture ADAM 4500 Series User s Manual 5 3 Chapter 5 Programming and Function Library Project BS EE Compile Debug BALA RMH 1 C H int SendAlarmMailtvoid gt Entry Exit Gode int MakeAlarmMailtvoid gt C options Advanced options int count 1 Optimizations Source void maintvoid gt Messages lt Hames unsign
205. lue Meaning MSG PEEK Peek at the incoming data The data is copied into the buffer but is not removed from the input queue MSG OOB Process out of band data See Also recv send socket 5 156 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library select Syntax int select int INfds fd set psReadfds fd set psWritefds fd set psExceptfds const struct timeval psTimeout Description Determines the status of one or more sockets waiting if necessary Parameters Description INfds This argument is ignored and included only for the sake of compatibility psReadfds An optional pointer to a set of sockets to be checked for readability psWritefds An optional pointer to a set of sockets to be checked for writability psExceptfds An optional pointer to a set of sockets to be checked for errors psTimeout The maximum time for select to wait or NULL for blocking operation Return Value select returns the total number of descriptors which are ready and contained in the fd set structures O if the time limit expired or SOCKET ERROR if an error occurred If the return value is SOCKET ERROR errno contains the specific error code Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EINVAL The psTimeout value is not valid ENOTSOCK One of the descriptor sets contains an entry which is not a socket ADAM 4500 Series User s Manual 5 157 Chapte
206. lue of INVALID SOCKET is returned and a specific error code is returned in errno The integer referred to by AddressLen initially contains the amount of space pointed to by psAddress On return it will contain the actual length in bytes of the socket address returned Error Codes ENETDOWN The network subsystem has failed EFAULT The piAddressLen argument is small less than the sizeof a struct sockaddr EINVAL listen was not invoked prior to accept EMFILE The queue is empty upon entry to accept and there are no descriptors available ENOBUFS No buffer space is available ENOTSOCK The descriptor is not a socket EOPNOTSUPP The referenced socket is not a type that supports connection oriented Service EWOULDBLOCK The socket is marked as non blocking and no connections are present to be accepted 5 122 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Remarks This function extracts the first connection on the queue of pending connections on listening socket so creates a new socket with the same properties as so 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 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 Socket so remains listening The argument psAdaress is a
207. 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 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 ensure that data is not lost or duplicated If data for which the peer protocol has buffer space cannot be successfully transmitted within a reasonable length of time the connection is considered broken and subsequent calls will fail with the error code set to ETIMEDOUT SOCK_DGRAM sockets allow sending and receiving of datagrams to and from arbitrary peers using sendto and recvfrom f such a socket is connect ed to a specific peer datagrams may be send to that peer send and may be received from only this peer using recv See Also accept bind connect getsockname getsockopt setsockopt listen recv recvfrom select send sendto ADAM 4500 Series User s Manual 5 177
208. mming and Function Library Timer Reset Syntax void Timer Reset int idx Description Reset the timer identified by the integer idx to its initial state Parameter Description idx Timer index Timer ID Return value None Remarks None Example Refer to Release All ADAM 4500 Series User s Manual 5 25 Chapter 5 Programming and Function Library Timer Set Syntax int Timer Set unsigned int msec Description Requests a timer from the microprocessor and then sets the time interval of the function Timer intervals are set in 5 millisecond increments The function return value is an integer representing the ID of the timer function when it is successful A return value 1 means the request failed Programmers should consider whether an assigned timer has timed out when programming for timer functions The value of the variable tmArriveCnt idx where idx is the timer ID can be checked to verify timer status Value of O indicates that the timer is still counting Values other than O mean the timer has timed out Parameter Description msec Time interval set max value is 65536 Return value 0 100 Function Succeed Value represents the timer ID 1 Function failure Remarks Timer function calls in the ADAM 4500 Series are emulated as timer functions in a PLC Applications using timer functions will run less efficiently if the more timer functions are running simultaneously in a program Example
209. mode 0 unBlock mode scanf 9ed amp tmpCOM if tmpCOM 0 RecvMode UnBlock_Mode else HecvMode Block Mode ifdef Product 5510 printf Enter COM port selection 1 COM1 2 COM2 3 COM4 5 46 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library scanf d amp tmpCOM if tmpCOM 1 tmpCOM COM1 else if tmpCOM 2 tmpCOM COMe else if tmpCOM 3 tmpCOM COM4 elif defined Product 4500 printf Enter COM port selection 1 COM1 2 COM2 3 COMG 4 COM4 scanf d amp tmpCOM if tmpCOM 1 tmpCOM COM1 else if tmpCOM 2 tmpCOM COMe else if tmpCOM 3 tmpCOM COM3 else if tmpCOM 4 tmpCOM COM4 endit else printf Wrong selection n return j printf Opening COM Port with 57600 baud n if SIO_Open tmpCOM 0 printf error n return if SIO_SetState tmpCOM unsigned long 57600 NO PARITY DATAS STOP1 20 printf Set State Error n return ADAM 4500 Series User s Manual 5 47 Chapter 5 Programming and Function Library SIO PurgeBuf tmpCOM Clear RXBuffer SIO PurgeBuf tmpCOM Clear TXBuffer while 1 if Mode 0 if GecvMode Block Mode if SIO_GetAvaiRecvBytes tmpCOM gt RecvDataLen if SIO_RecvBytes tmpCOM Block_Mode RecvDataLen Data RecvDataLen if Data RecvDataLen 1 0x0d Mode 1 Idx 0 else printf Error Receive n return else printf Error Receive n return else
210. ms SIO GetModemStatus Syntax CHAR SIO GetLineStatus UCHAR i ucPort CHAR SIO SetLineParams UCHAH i ucPort UCHAR i ucParams CHAR SIO_GetModemStatus UCHAR i ucport Description SIO GetLineStatus Reads line control register of specific COM port SIO SetLineParams Writes to line control register of specific COM port SIO GetModemsStatus Reads modem status register of specific COM port Parameter Description ucPort The Port number you want to use see remarks ucParams UART register parameter refer to Appendix A for the 16C550 UART register document Return value If success return the UART register value refer to Appendix A for the 16550 UART register document If fail return a negative number as follows Illegal Setting 5 Remarks Parameter Value Description COM COM Ra COM2 COM2 COM3 COM3 COM4 COMA ADAM 4500 Series User s Manual 5 55 Chapter 5 Programming and Function Library SIO LowerRaise RTS DTR Syntax CHAR SIO LowerRaise RIS DTR UCHAR i ucPort UCHAR i ucL R Mode UCHAR i ucSignal Description Lower or raise the RTS DTR signal Parameter Description ucPort The Port number you want to use see remarks i ucL R Mode Decide to raise or lower signal see remarks i ucSignal Decide to set RTS or DTR signal see remarks Return value If success return O If fail return a negative number as follows Illegal Setting 5 Remarks COM1 COM1 ul R Mode Ra
211. n many contemporary packet switched networks such as Ethernet Broadcast messages may be sent and received Establishing Remote Connections To establish a connection one side the server must execute a listen and and subsequent accept and the other side the client a connect A connection consists of the local socket remote socket pair It is therefore possible to have a connection within a single host as long as the local and remote port values differ Each host in an IP network must have at least one host address also known as an IP address When a host has more than one physical connection to an IP network it may have more than one IP address An IP address must be unique within a network An IP address is 32 bits in length a port number 16 bits A value of zero means any while a binary value of all 1s means all The latter value is used for broadcasting purposes Using the sockaddr structure conveys the addresses host port to be used in a connection A local association is performed by the bind function Using SOCK STREAM and SOCK DGRAM Services When using the SOCK STREAM service TCP bi directional data can be sent using the send or sendto functions and received using the recv or recvfrom functions until one side performs a shutdown 1 or shutdown 2 after which that side cannot send any more data but can still receive data until the other side performs a shutdown 1 shutdown 2 or closesocket
212. n r read files ADAM 4500 Series User s Manual 7 9 Chapter 7 HTTP and FTP Server Application HTTP Rights e get files p post files g use CGI m use remote console Fields should be separated by single spaces If any field is missing the entry is ignored A comment may follow the last field permissions of the line Format of htaccess Any directory may contain this file and serve as overrides to the general permissions for the containing directory and all its subs until another htaccess is found This file consists of lines where each line contains a user s information A line starting with a is considered a comment and is ignored Each line consists of three fields Username Password Permissions comment of Username The name of this user If it is it will be used when the client does not specify a username Password This users password If it is no password is required Permissions Operations allowed Permission are listed below e User may get files p User may post files g User may use cgi Fields should be separated by single spaces lf any field is missing the entry is ignored A comment may follow the last field permissions of the line Note If a default user is supplied it should always appear first in the list of users Only users below the default user will be considered 7 10 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Application FTP Serv
213. n mode voltage of balanced RS 485 systems the 18 k on the input can be taken as being in series across the input of each individual receiver If thirty of these receivers are put closely together at the end of the transmission line they will tend to react as thirty 36k resistors in parallel with the termination resistor The overall effective resistance will need to be close to the characteristics of the line The effective parallel receiver resistance Re will therefore be equal to Re 36 x 107 30 12000 While the termination receptor Rrwill equal Rr Ro 1 Ro Re Thus for a line with a characteristic impedance of 100 resistor Rr 100 1 100 1200 110 Since this value lies within 1096 of the line characteristic impedance B 6 ADAM 4500 Series User s Manual Appendix B RS 485 Network Thus as already stated above the line termination resistor Rr will normally equal the characteristic impedance Zo The star connection causes a multitude of these discontinuities since there are several transmission lines and is therefore not recommend Note The recommend method wiring method that causes a minimum amount of reflection is daisy chaining where all receivers tapped from one transmission line needs only to be terminated twice B 3 RS 485 Data Flow Control The RS 485 standard uses a single pair of wires to send and receive data This line sharing requires some method to control the direction of the data flow RTS Reque
214. n 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 See Also connect listen getsockname setsockopt socket ADAM 4500 Series User s Manual 5 125 Chapter 5 Programming and Function Library closesocket Syntax int closesocket SOCKET so Description Closes a socket Parameters Description SO A descriptor identifying a socket Return Value If no error occurs closesocket returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed ENOTSOCK The descriptor is not a socket EWOULDBLOCK The socket is marked as nonblocking and SO_LINGER is set to a nonzero timeout value Remarks This function closes a socket More precisely it releases the socket descriptor so so that further references to so will fail with the error ENOTSOCK 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 Type of SO_DONTUNGER SO_UNGER SO LINGER Yes 5 126 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library If
215. n_files onto drive D under Webroot directory Put switch into Initial mode ADAM 4500 Series Utility Ver 1 13 ADAE RET Sois i ojej ajele xim a 3 A iu Ten Ll HRA qc A iL R Apika a IE EEN Appkcahon m reed DFI Appin i j DOCU Appbestior r1 CED Agpkcabeon ei IEE HTML Po 4 7 objects 27 30 Z obiectis 157 1 TOG O40 bytes Free SOCKETP EXE 48 885 07 04 2006 Tra 6 File s O7 664 bytes TOUB 048 bytes reu ld cd wWEBROCT dir Volume in drive D has no label Volume Serial Humber is 3646 10E Directory of D wWwEBROOT lt DIR gt 07 04 2005 3 772 IDIR 07 04 7006 g 27a PETPD EXE 64 256 07 04 2006 4 7Ha n EXE 45 440 07 04 7006 9 374 4 fileja 109 696 bytes 706 048 bytes ree sa 5 L3 n Adan rsuo Wi 103m uM ADAM 4500 Series Utility Ver 113 k la xi FP ten exe 46H Appian JON 8 On AM SHTO SMR Apgahons SOROS D A Eeee aa GM agpiceticn 86300 iiD AM 7 abiectis 2AT 3kR 5 obyectis 155 4 CESS Por bytes Frea i cd WEBROOT Ait Volume in drive Db has oo Lata Volume Serial Number is i Directory of D gt WENROOT ITIPETPD EXE FTPD XE Dr WEHBRUOCOT isa 5 Y L3 n Adam rsuo WI i0 aM ADAM 4500 Series User s Manual 4 17 Chapter 4 Guidelines for Network Functions 2 Using ADAM PRJ to Build ADAM EXE under ADAM 4500 Series Utility Source Example httpEx and download ADAM EXE onto drive D under Webroot directory HII ADAM 4500 Se
216. nals TxD RxD RTS CTS DTR DSR DCD RI GND Mode Asynchronous full duplex point to point Connector DB 9 pin Transmission speed Up to 115 2 Kbps e Max transmission distance 50 feet 15 2 m ADAM 4500 Series User s Manual 1 7 Chapter 1 System Overview 1 3 3 RS 485 interface COM2 amp COM3 e Signals DATA DATA Mode Half duplex multi drop Connector Screw terminal Transmission speed Up to 115 2 Kbps Max transmission distance 4000 feet 1220 m 1 3 4 RS 485 232 interface COM4 and programming port e RS 232 485 Mode Selectable Select by jumper setting e RS 232 Mode Programming port Full duplex point to point Signals TxD RxD GND e RS 485 Mode Half duplex multi drop Signals DATA DATA Connector Screw terminal e Transmission speed Up to 115 2 Kbps Max transmission distance RS 232 50 feet 15 2 m RS 485 4000 feet 1220 m 1 3 5 Power e Unregulated 10 to 30 VDC Power consumption 2 0 W Typically 1 3 6 Mechanical Case ABS and PC Plug in screw terminal block two 9 pin plug in screw terminals Accepts 14 22 AWG 0 6 1 6 mm2 1 3 7 Environment Operating temperature 10 to 70 C 14 to 158 F e Storage temperature 25 to 85 C 13 to 185 F e Humidity 5 to 95 non condensing e Atmosphere No corrosive gases Note Equipment will operate below 30 humidity However Static electricity problems occur much more frequently Make sure you tak
217. nect amp SO_ 4500 return 0 5 108 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library else adv printf Adam 5051 Status for tmp 0 tmp DataByteCount tmp adv_printf 2X HostData tmp j adv printf n j ADAM 4500 Series User s Manual 5 109 Chapter 5 Programming and Function Library ADAMModbusTCP Read Syntax bool ADAMModbusTCP Read SOCKET j SO int WaitMilliSec int Slave Addr unsigned long i iStartAddr unsigned long i iEndAddr unsigned int o iByteOfResp unsigned char o szResp Description Reads the On OFF status of OX 1X references coils or the binary contents of 3X 4X references registers in the slave Parameters Description SO The socket connected to Modbus TCP server WaitMilliSec The maximum time of ADAMModbusTCP_Read Slave Addr Address ID of slave device valid slave device addresses id are in the range of 0 247 decimal iStartAddr The start address of slave device i iEndAddr The end address of slave device iTotalPoint The total number of coils regs to be read o iByteOfResp The total bytes of the response data contents Oo szHRHesp The buffer of response data contents Return value ADAMModbusRTU HRead returns TRUE if it is successful On an error a value of FALSE will be return and the function Error Code can be used to get the last error Example please refer the examples under C Program Files Advantech ADAM 4500 Series Utility Sourc
218. nel or AllChannels i ucChannel SingleChannel the channel you use AllChannels don t care o ulValue DIO value read from module i ulValue DIO value wrritten to module Return Value If success return O If fail returns a negative number as follows Illegal Setting b Board Not Exist 7 Remarks None ADAM 4500 Series User s Manual 5 35 Chapter 5 Programming and Function Library Ver HIOLib Syntax void Ver HlOLib char vstr Description Get HIO Library version Parameter Description vstr Pointer to array of HIO Library version information Return value None Example char library ver 20 void main void Ver HlOLib library ver adv printf The version of library is s n library ver j Remarks None 5 36 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library DIO Example Refer to C Program Files Advantech ADAM 4500 Series Utility Source Example Basic_Function Ex2 C for this example include 4500drv h void main int tmpCnt 0 char c unsigned char type unsigned long div dov char Ver_Str 30 Ver HlOLib Ver Str printf The HIO library version is s n Ver Str First scan for the existing IO modules type Get BoaralD Show the module type of each slot on the screen if type EB5O ID printf IO slot is EB50 WM else printf IO slot is Nul printf press any key to continue n getch
219. ns and unload The width and height of the screen area to serve for the remote console session These values default to 80 and 25 respectively 7 14 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Application ScreenBufferSegment ScreenBufferOffset Together a pointer to the top left corner of the display memory to serve for the remote console session These values default to B000 and 0000 respectively for monochrome display adapters and to B800 and 0000 respectively for color display adapters MemorySize The maximum amount of memory available to the server The default value is 32K The value of m can range from 8192 to 63472 MaximumConnections The maximum number of simultaneous connections allowed by the server InterruptNumber The interrupt number to access the CGI API http port HTTP port to listen on This parameter defaults to the standard HTTP port number of 80 fto port FIP por to listen on This parameter defaults to the standard FTP port number of 21 rc port Remote Console port to listen on This parameter defaults to 81 Configuration File HTTPFTPD uses the standard SOCKET UPW file for validating logins The file is composed of text lines each representing a login name password and the configuration to use for a session opened with those credentials Space characters separate the parameters in the file which are in the following format name password directory rights The locati
220. nter Value to set Stack Pointer to Return value None Constants and Definitions used by CGI API Refer to HTAPIC H SSI Definitions and functions Refer to SSI H 5 210 ADAM 4500 Series User s Manual 6 Sockets Utility Chapter 6 Sockets Utility M utilities make use of command line parameters and or configuration files Please be careful to note the name and location of the configuration file used by the application you are working with All SOCKETS applications require that the kernel be loaded before the application is run in order to function properly You can find all these SOCKETS utilities under C Program Files Advantech ADAM 4500 Series Utility Source Drive_D Extension_files Refer to image below When you need to use the utilities remember to download the execution file to ADAM 4500 Series Controller fill ADAM 4500 Series Utility Yer 1 13 l x File Help Local System ADAM 4500 Series CIR 20 E 8 Fd Sct E 4 B3 sa il cowv C Program Files Advantech 4D4M 4500 Series UtilityiSo v Y Size Type Modified Sie Twe Modifie C3 WebRoot File Folder 5 1572 Cxconr File Folder 2008 07 03 4 02 00 AM E dhcpstat 19KB Application 4 13 2 Cj WEBROOT File Folder 2005 07 03 4 02 00 AM F httpget 39KB Application 4 13 2 fs AUTORUN BAT 1KB MS DOS B 2006 07 03 4 03 00 AM Fist 25KB Application 4 137 i 4x8736 COM 13KB MS DOS A 2006 07 03 4 02 00 AM EJ ipsta
221. nting a login name password and the configuration to use for a session opened with those credentials Space characters separate the parameters in the file which are in the following format name password directory rights The location of the username password file to be used by the server is specified by the environment variable SOCKETS as follows YSOCKETS SOCKET UPW If the variable SOCKETS is not specified the following file is used DLISOCKETS SOCKET UPW Configuration File Parameters name The login name of this record password The password to authenticate a user trying to login as this name directory The starting directory for this user rights Up to four characters specifying which permissions this user is granted r means that this user has read access w means that this user has write access c means that this user has permission to make new directories d means that this user has permission to change to a directory other than his starting location and subdirectories from the starting location Example Socket upw Admin admin c drwc Guest c guest dr Example Command Line FTPD m 40000 r 7 12 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Application FTP Server Commands The following commands are recognised by the SOCKETS FIP server Command Description Abort cancel an incomplete transfer append out a file at the server but append it if cwd directory dele file lis
222. ntitled Modbus File Add Edit View Help maj eel Devicel CC x Name Tag Description l Cancel Location mo JinputCol Data Type ET Number of Bytes o Scaling Enable Settings Simulation signal Ramp z Ready Device1 has 0 Tags 4 48 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 7 Click menu View get from ADAM 4500 Series Controller File Add Edit view Help Coil Input Monitor under to see the value 281 xl 010001 Monitor tag values Device1 has 1 Tags You can see the DIO value of ADAM 4500 Series Controller 3 untitled Modbus E File Add Edit View Help i S JESL 28 xi Device1 Name Type Location Processing f Value Mapescripion ag Coil Input 010001 Ready Devicel has 1 Tags ADAM 4500 Series User s Manual 4 49 Chapter 4 Guidelines for Network Functions DEMORS C include lt stdio h gt include lt dos h gt include lt time h gt include lt conio h gt include 4500drv h include RTU h define MAXDATASIZE 100 define sizeofShareMem 10 int count void main unsigned int Share Mem sizeofShareMem char cCh char LSR State unsigned int tmpcnt tmpcntl unsigned long div if Modbus_COM_Init COM2 Slave unsigned long 9600 NO PARITY DATAS STOP 0 printf errori return j printf init success Nn ADAMRTU ModsServer Create 3 uns
223. nts File Folder 6 16 2006 4 JEJ 7 object s o byte s L start S 3 W iii adamasoo Sw 3 10PM 3 6 ADAM 4500 Series User s Manual Chapter 3 Program Download 3 Click the Refresh Folder button to display the files and directories on the drive D of ADAM 4500 Series Controller HIT ADAM 4500 Series Utility Ver 1 13 File Help Local System ADAM 4500 Series Se LINO 3072 3074 Local Disk CONF File Folder 2006 0646 1 00 00 AM w Removable Disk Removabl C WwEBROOT File Folder 2006 0616 1 00 00 4M s Removable Disk Removabl fS AUTORUN BAT 1KB MS DOS B 2006 0616 1 00 00 AM a ADV SRAMDRV Removabl Et AX8796 COM 13KB MS DOS A 2006 0616 1 00 00 4M G Control Panel System Fol craio EXE 35KB Application 2006 0646 1 00 00 AM Shared Documents File Folder 3 1 2006 9 sockETP EXE 48KB Application 2006 0646 1 00 00 AM My Documents File Folder 6 16 2006 7 objects o byte s 6 object s 95 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF DIR 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 1 02a CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free m start S 2 Wy aii adamasoo TL 3 11PM 4 Click the Config ADAM button to test
224. o byte s l6 object s 95 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF lt DIR gt 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 1 02a CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free m d star S 3 W iii adamasoo TL 3 11PM ADAM 4500 Series User s Manual 8 11 Chapter 3 Program Download 3 Select HTTPFTP Server and click the Go button This means both HTTP and FTP server will be initialized Ml ADAM 4500 Series Utility Ver 1 13 a 12 x File Help Local System ADAM 4500 Series a wem e um cow z C Program Flies Advantec ec m Configuration E Name Adam 4500 Series System Conf amp Init O webRoot M System Configuration E dhepstat IP DHCP httpaet StaticlIP C DHCP Obtain DNS address automatically Address I 35 Ff Jg Primary DNS ipstat IMAKEMAIL Gateway Bo Update FTP amp HTTP Configuration FTP 02 00 AM 02 00 AM 02 00 AM 02 00 AM 02 00 AM 04 00 AM 1 03 00 AM 03 00 AM HEIE ID ID Password Password l object s f175 c Rights Change Dir Rights J Get Files Creat Del Dir PostFiles Write File Use CGI Read File Update System In
225. o finish the backup process fl ADAM 4500 Series Utility Ver 1 13 File Help Local System pu Name Size Type Modified Se LINO 3072 3074 Local Disk CONF File Folder 2006 0649 7 01 00 AM Removable Disk Removabl YVEBROOT File Folder 2006 0649 7 01 00 AM Removable Disk Removabl S AUTORUN BAT 1KB MS DOS B 2006 0619 8 00 00 4M s ADV SRAMDRY Removab el A MOTOR COM 1 X B MS DOS A 2006 06 19 7 01 00 AM e Control Panel System Fi x B Application 2006 0649 7 01 00 AM O My Documents File Folde Read Image 7 object s lo byte s AX8796 COM CFGIO EXE Please wait system is under making backup image Message SOCKETP EXE 6 file s C transfer R D lt lt Transferring Fi lt lt Get ACK for EOT gt gt D NWORKERRD 2 3 4 5 A start ayo iii Adam4500 3 26 ADAM 4500 Series User s Manual i81 xl ADAM 4500 Series Shared Documents File Folde amp dam 4500 e B Application 2006 06 19 7 01 00 AM i re m a cow Modified Read image Successfully Please reboot Adam 4500 wr AURORA 5 8 bytes free ber Wy WA 8 33PM Chapter 3 Program Download 3 8 Restore the drive D from image file Following steps will demonstrate how to restore image file to drive D In this example we will use the image file produced in section 3 7 1 Put switch into Initial mode and then reboot
226. on of the username password file to be used by the server is specified by the environment variable SOCKETS as follows YSOCKETS SOCKET UPW If the variable SOCKETS is not specified the following file is used DLISOCKETS SOCKET UPW ADAM 4500 Series User s Manual 7 15 Chapter 7 HTTP and FTP Server Application Configuration File Parameters name The login name of this record password The password to authenticate a user trying to login as this name directory The starting directory for this user w means that this user has write access c means that this user has permission to make new directories d means that this user has permission to change to a directory other than his starting location and subdirectories from the starting location e means that this user may get files p means that this user may post files g means that this user may use cgi m means that this user may use Remote Console Example Command Lines HTTPFTPD m 40000 r HTTPFTPD a 80 25 v a000 0000 r 7 16 ADAM 4500 Series User s Manual Appendix A COM Port Register Structure Appendix A COM Port Register Structure This appendix gives a short description of each module s registers For more information please refer to the STARTECH 16C550 UART chip data book All registers are one byte Bit 0 is the least significant bit and bit 7 is the most significant bit The address of each register is specified as an offset from the port base addre
227. onfiguration Wiring ADAM 4500 Series User s Manual 2 9 Chapter 2 Installation RS 232 Network Connection for System Monitoring and Integration Since the connection for an RS 232 interface is not standardized different devices implement the RS 232 connection in different ways If you are having problems with a serial device be sure to check the pin assignments for the connector We provide one cable to transfer RJ 48 COM1 connector on ADAM 4500 Series Controller to DB9 The following figure shows the pin assignments of the DB9 connector for the ADAM 4500 Series Controller COM1 RS 232 port GND Os pr o RI TX O i CTS Rx a RTS pep O1 DSR Figure 2 11 Pin Assignment of COM1 RS 485 Network Connection for System Monitoring and Integration The ADAM 4500 Series Controller provides RS 485 interfaces for multi drop network integration The COM2 amp COM3 are dedicated RS 485 interface The COM4 is an RS 232 485 selectable COM port They are able to support the Modbus RTU master and slave functions 2 10 ADAM 4500 Series User s Manual Chapter 2 Installation Guidelines Ethernet Network Connection The ADAM 4500 Series Controller provides Ethernet interface RJ 45 type for network integration Usually you will need to prepare an Ethernet switch like as ADAM 6520 or hub for connecting to other network devices as following figure ADAM 6520 Ethernet Switch i Y at E um Mg
228. or gethostbyname exit I 4 68 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions if SO 4500 socket AF INET SOCK STREAM IPPROTO TCP INVALID SOCKET perror socket exit I j Server_addr sin_family AF_INET Server_addr sin_port htons Server_Port Server_addr sin_addr struct in_addr he gt h_addr memset amp Server_addr sin_zero 0 amp if connect SO 4500 struct sockaddr amp Server addr sizeof struct sockaddr SOCKET ERROR perror connect exit I j while 1 if numbyteszrecv SO 4500 buf MAXDATASIZE 1 0 SOCKET ERROR perror recv exit I if numbytes gt 0 i printf Received s buf memset buf 0 sizeof buf if tmpcount 2 0 str sirl else str str2 sleep 1 if send SO 4500 str strlen str 0 SOCKET ERROR ADAM 4500 Series User s Manual 4 69 Chapter 4 Guidelines for Network Functions perror send exit I j tmpcount if tmpcount gt 100 tmpcount 1 j else closesocket SO 4500 break j j return 0 j 4 70 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 9 UDP Connection Example program USERVER EXE and UCLIENT EXE source file UDP SERVER C and UDP CLIENT C under ADAM 4500 Series Utility Source Example TCP directory Hardware configuration see figure below f Host PC J A
229. ot r System Configuration 01 00 AM E dhepstat IP DHCP Ef htipget StaticIP o DHCP J Obtain DNS address automatically E Address i32 fies fi fa Piman d J J ipsta FA MAKEMAIL Gateway 255 255 255 fo CI SENDMAIL Ef ping M FTP amp HTTP Configuration FTP HTTP ID user ID user Password HHHH Password HHHH 8 object s io Rights v Change Dir Rights v Get Files Directory v Creat Del Dir v PostFiles a Iv Write File IV Use CGI E v Read File HITPFTPD EX JUR Update C transfer TE Initializati fe CTE ES ystem Initialization lt lt Get ACK f 9 System Files HTTPFTP Server FTP Server HTTP Server Go d start W EJ lb Adam4soo Note and one user for HTTP server S mS 7 31PM This utility can only let you configure one user for FTP server If you would like to configure multi users for FTP server and HTTP server please refer to chapter 4 6 Click the OK button to finish the configuration 81 xi ADAM 4500 Series Pon 8 e E Ye ER EFH wa E sa i cow gt IC Program FilesvAdvantec E eas xi M Adam 4500 Series System Conf amp Init M System Configuration IP DHCP Static IP DHCP Address 122 fies AL Ja Gateway 255 J255 255 Jo M FTP amp HT TP Configuration 5 FTP Password sti Rights JY Change Dir v Creat Del Dir IV Write File JV Read
230. otalByte Byte Count o szDatal Register Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example if ADAMRTU_ReadInputRegs COM1 0x02 0x65 0x01 amp DataByteCount HostData adv printf err code is d n Error Code adv printf fail send else adv printf Status for tmpcnt 0 tmpcnt DataByteCount tmpcnt j adv printf n adv_printf 02X HostData tmpont 5 84 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMRTU ReadinputStatus Syntax bool ADAMRTU ReadinputStatus int iPort int i iAddr int iStartlndex int iTotalPoint int o iTotalByte unsigned char o szData Description 02 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave Address iStartIndex Starting Address iT otalPoint No of Points o iTotalByte Byte Count o szData Inputs Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example If ADAMRTU ReadlnputStatus COM 1 0x02 0x64 0x08 amp DataByteCount HostData adv printf err code is d n Error Code adv printf fail send else adv printf Status for tmpcnt 0 tmpcnt DataByteCount tmpcnt adv_printf 02X HostData tmpont j adv printf n ADAM 4500 Series User s Manual 5 85 Chapter 5 Programming and
231. p window 2920 ADAM 4500 Series User s Manual 4 3 Chapter 4 Guidelines for Network Functions Format of SOCKET UPW This is the same file used for the HTTP and FTP server s FTPD EXE permissions This file consists of lines where each line contains a users information A line starting with a is considered a comment and is ignored Each line consists of four fields Username Password Working Directory gt Permissions comment of Username The name of this user If it is it will be used when the client does not specify a username Password This users password If it is no password is required Working Directory The user will only have access to this directory and its subdirectories If it is f this user has access to the whole system HTTP DIR can be referred to as If a relative path is specified it is appended to HTTP DIR Permissions When a user is granted both FIP and HTTP permissions the FIP permissions must appear first otherwise they will be ignored Permission are listed below FTP Rights d change directories C create delete directories Ww write files r read files HTTP Rights e get files p post files g use CGI m use remote console Fields should be separated by single spaces If any field is missing the entry is ignored A comment may follow the last field permissions of the line 4 4 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Funct
232. password file controls authentication Authentication is user specific and may also differ from directory to directory It may also be put off for either some or all users See the section on authentication The HTTP server can support multiple simultaneous sessions The GET and POST request methods are implemented as well as the following MIME types text html text plain image gif image jpeg image jpeg and application octet stream The MIME type is determined by the file extension Remote Console Server Initialization The client browser will initialize a remote session An HTTP connection will be made to the HTTP server The downloaded page will contain the applet that will automatically connect to the RCS on TCP port 81 An example download page iS supplied as REMCON HTM Almost any application e g a text editor can be run on the server The remote keyboard and display control the application as if they were locally attached On the remote side the Java Applet acts as a simple terminal emulator that displays what it receives from the server and sends what is entered from the keyboard to the server It is not required to have a real display adapter on the embedded system server only to have display buffer memory When a new connection is made all the screen data as well as the cursor position is sent to the client Subsequently the RCS keeps a watch on the video memory and cursor position and whenever a change is de
233. pense requirements 1 2 2 RS 232 485 communication ability The ADAM 4500 Series Controller has four serial communication ports giving it excellent communication abilities This facilitates its ability to control networked devices The communication ports of different models are listed as below table IDEEN ADAM 4501 4501D COM1 RS 232 Full modem signal COM2 RS 485 COM3 RS 485 PRS ABS Table 1 1 Communication Ports of ADAM 4501 4501D Controller ADAM 4501 4501D COM1 is a dedicated RS 232 port COM2 and COMS are dedicated RS 485 port and the fourth communication port is shared by COM4 and Programming port It is a selectable port by using jumper ADAM 4500 Series User s Manual 1 3 Chapter 1 System Overview These four ports allowed the ADAM 4501 4501D to satisfy diverse communication and integration demands Programming port is for downloading or transferring executable programs from a host PC to ADAM 4500 Series Controller It can also be used as an RS 232 communication port Refer to section 2 2 1 to see how to configure COM4 as Programming X port or standard RS 232 communication port Please refer to following figure to check the location of COM ports Ethernet Data Acquisition Modules ADAM arcon CO ADAM 4501 RS 232 Full Modem Signals Prog COM4 R9 232 TX Rx GND NORMAL B INIT Figure 1 1 ADAM 4501 Communication Ports 1 4 ADAM 4500 Series User s Manual Chapter 1 System Overview 1 2 3 Ve
234. performs stack and context switches and provides ordinary C functions to access the http server HT TPD exe The header file to use is CGIADAP H The API may be used without using CGIADAP by making low level calls which are detailed below In this case the user must perform the required stack and context switches if required ADAM 4500 Series User s Manual 5 199 Chapter 5 Programming and Function Library HttpRegister Syntax int HttoRegister char far szPath int far X pfCallback HTTP PARAMS far psHttpParams int Flags DWORD dw UserID Description The HttpRegister function registers an interest in a URL providing a callback function The callback is guaranteed to only be called when DOS can be called The DOS critical handler will be disabled and all critical errors will result in an access error without any user intervention Since the callback happens at interrupt time it should execute for as short a time as possible After a done or error return no further callbacks will be generated for the current request Only one callback will be active at any time Calling an API function while executing the callback function will not result in another callback before the current callback has returned Parameters Description szPath Far pointer to the string identifying a URL It should be an exact match of the abs path part of the URI minus the leading 7 For instance If you want to capture all _http myserver com
235. plement your program in this function static char ptr OO 0 char tmpStr 0 static char Htm Content HTTP 1 0 200 OK r n content of html page content 1 Content type text htmN n n means refreshes every I second html META HTTP EQUIV Refresh content 1 gt lt b gt The extension board ID is 9OOOOOOO b p lt html gt ADAM 4500 Series User s Manual 4 15 Chapter 4 Guidelines for Network Functions number printf Refresh Yd times n number if ptr OO pir OO strstr Htm Content DOO sprintf tmpStr Ox X Get BoardID ReplaceStr ptr OO tmpStr 7 HttpSendData psParams iHandle Htm Content strlen Htm Content return RET DONE j void ReplaceStr char ptr_strl char ptr str2 int len str replace string int i for i 0 i len str i ptr str1 i 32 for i 0 i lt strlen ptr_str2 i ptr strl1 i ptr str2 i 4 16 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions lt lt Example 2 gt gt Example program ADAM EXE with CGI function Source file ADAM C and WEBADAM htm under ADAM 4500 Series Utility Source Example httpEx directory refer to Page 4 21 Utility HTTPD EXE System configuration Running HTTP server on ADAM 4500 Series Controller Using Web Browser to connect to the HTTP server on Host PC 1 Download HTTPD EXE under ADAM 4500 Series Utility Source Drive_D Extensio
236. printf send Alarm mail prepare n if spawnlp P_WAIT d nail sendmail exe d nail sendmail ex e argl arg2 NULL 1 j return 0 return l j Note Please refer to Chapter 6 Page 6 10 and 6 11 to see more detail about Mail Function 4 32 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 4 Modbus TCP Server Example program DEMOTS EXE Source file DEMOTS C under ADAM 4500 Series Utility Source Example DemoModbus directory Hardware configuration see figure below mi Host PC anc Download program COM Port ADAM 4500 Series Controller Modbus TCP Server Ethernet port Modbus TCP f Ethernet port Software application on another PC ex OPC Server Modbus TCP Client This example uses ADAM 4500 Series Controller as Modbus TCP server and a PC on the same Ethernet network is Modbus TCP client ADAM 4500 Series Controller writes on board DIO value to address 40001 and Modbus TCP client application such as OPC Server or ADAMVIEW read the value from that address Address 0 of share memory represents the address 40001 of Chapter 4 Guidelines for Network Functions Modbus address 4 34 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 1 Click the Adam 4500 Configuration button to set IP address of ADAM 4500 Series Controller Put switch into Initial mode i ADAM 4500 Series Utility Ver 1 14 i File Help
237. pter 4 Guidelines for Network Functions if bind Host Sock struct sockaddr amp Host addr sizeof struct sockaddr SOCKET ERROR perror bind exit I j pulArgp l if ioctlsocket Host_Sock FIONBIO amp pulArgp perror ioctlsocket exit I printf wait for client send message n while 1 hasMessage Host_WaitForMessage Host_Sock 0 if hasMessage addr len sizeof struct sockaddr if numbytes recvfrom Host Sock buf sizeof buf O struct sockaddr amp Client addr amp addr_len SOCKET_ERROR perror recvfrom if errno EWOULDBLOCK printf EWOULDBLOCK break j buf numbytes 0 printf got packet s from Ys n buf inet_ntoa Client_addr sin_addr if numbytes sendto Host_Sock ackmsg strlen ackmsg 0 struct sockaddr amp Client addr sizeof struct sockaddr SOCKET_ERROR 4 76 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions perror sendto break j j j closesocket Host_Sock return 0 j int Host_WaitForMessage int serverSocket int i_iWaitMilliSec fd set FdSet struct timeval waitTime FD ZERO amp FdSet FD SET serverSocket amp FdSet waitTime tv sec i IWaitMilliSec 1000 waitTime tv usec i iWaitMilliSec 1000 1000L if select 0 amp FdSet NULL NULL amp waitTime 0 return TRUE return FALSE ADAM 4500 Series User s Manu
238. puter this signal offers a reference point of the electronic circuit inside the computer f we want to communicate with this computer both Signal Ground and Frame Ground should be connected to make a reference point of each other s electronic circuit Generally speaking it is necessary to install an individual grounding bar for each system such as computer networks power systems telecommunication networks etc Those individual grounding bars not only provide the individual reference point but also make the earth our ground C 4 ADAM 4500 Series User s Manual Appendix C Grounding Normal Mode amp Common Mode Neutral 1 Llve Hot 9 Ground LS Normal Mode refars to defects occurring between the live and nautral conductors Normal mode Is sometimes abbreviated as NM or L N far live to neutral Common Mode refers to dafacts occurring batween alther cenducter and ground It is sametimes abbreviated as CM or N G for neutral to ground Figure C 3 Normal mode and Common mode C 1 3 Normal Mode and Common Mode Have you ever tried to measure the voltage between a live circuit and a concrete floor How about the voltage between neutral and a concrete floor You will get nonsense values Hot and Neutral are just relational signals you will get 110VAC or 220VAC by measuring these signals Normal mode and common mode just show you that the Frame Ground is the most important reference signal
239. quence of coilds OX references Parameters Description iPort COM port number Slave_Addr Address ID of slave device valid slave device addresses id are in the range of 0 247 decimal iStartAddr The start address of slave device i iEndAddr The end address of slave device i szData The buffer of query data contents Return value ADAMModbusRTU Write returns TRUE if it is successful On an error a value of FALSE will be return and the function Error Code can be used to get the last error Example please refer the examples under C Program Files Advantech ADAM 4500 Series Utility Source Example ModbusAppEx ADAM 4500 Series User s Manual 5 81 Chapter 5 Programming and Function Library ADAMRTU ReadCoilStatus Syntax bool ADAMRTU_ReadCoilStatus int iPort int i iAddr inti iStartIndex inti iTotalPoint int o iTotalByte unsigned char o szDatal Description 01HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave Address iStartIndex Starting Address iTotalPoint No of Points o iTotalByte Byte Count o szData Coil Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example if ADAMRTU_ReadCoilStatus COM1 0x02 Ox6E 0x01 amp DataByteCount HostData adv printf err code is d n Error Code adv printf fail send else adv printf Status for tmpcnt 0 tmpcnt DataB
240. r 5 Programming and Function Library Remarks 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 and the same as that used in Winsock The parameter psReadfds identifies those sockets which are to be checked for readability If the socket is currently listen ing it wil be marked as readable if an incoming connection request has been received so that an accept is guaranteed to complete without blocking For other sockets readability means that queued data is available for reading or for sockets of type SOCK STREAM that the virtual socket corresponding to the socket has been closed so that a recv or recvfrom is guaranteed to complete without blocking If the virtual circuit was closed gracefully then a recv will return immediately with O bytes read if the virtual circuit was reset then a recv will complete immediately with the error code ECONNRESET The presence of out of b
241. r 6 Sockets Utility 6 1 Chapter 7 HTTP and FTP Server Application 7 1 Appendix A COM Port Register Structure A 1 Appendix B RS 485 Network esee B 1 Appendix C Grounding Reference C 1 1 System Overview Chapter 1 System Overview 1 1 Introduction Standalone Data Acquisition and Control System As the growth of PC based technology Advantech PC based Programmable Controllers have been widely applied in variety of industrial automation applications Shrunk from the original ADAM 5510 series controller the ADAM 4500 Series Controller is a new series of stand alone programmable communication controller It does not only support high memory capacity user friendly configuration tool rich serial communication interfaces but also support Ethernet port available and original libraries on specific models Applying the ADAM 4500 Series Controller the C programmers would be able to handle any complex task easily The ADAM 4500 Series Controller is a compactsized Ethernet enabled communication controller under x 86 CPU architecture It supports not only Ethernet interface but also 4 serial ports which lets ADAM 4500 Series Controller be very suitable for industrial communication and control applications The Ethernet enab
242. r RTU Mod 5 2 5 Category E MODBUS TCP Functions MBTCP LIB Ver TCP Mod Modbus TCP Client Functions ReturnErr code ADAMTCP Connect ADAMTCP Disconnect ADAMTCP ForceMultiCoils ADAMTCP ForceSingleCoil ADAMTCP PresetMultiRegs ADAMTCP PresetSingleReg ADAMTCP ReadCoilStatus ADAMTCP ReadHoldingRegs ADAMTCP ReadlnputRHegs ADAMTCP ReadlnputStatus Modbus TCP Server Functions ADAMTCP ModServer Create ADAMTCP ModsServer Update ADAMTCP ModServer Release ADAM 4500 Series User s Manual 5 9 Chapter 5 Programming and Function Library 5 2 6 Category F Socket Functions SOCKET LIB Socket function accept ind closesocket onnect ioctlsocket etpeername etsockname etsockopt tonl tons inet addr inet ntoa i recvfrom elect end sendto setsockopt shutdown socket aprep Database function gethostbyaddr gethostbyname gethostname getservbyport getservbyname getprotobynumber getprotobyname 5 10 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 2 7 Category G HTTP Functions CGI_LIB LIB Socket function HttpRegister HttpDeRegister HttpGetData HttpSendData HttpSubmitFile HttpGetStatus HttpGetVersion GetStackPointer GetStackSegment SetStackPointer SetStackSegment ADAM 4500 Series User s Manual 5 11 Chapter 5 Programming and Function Library 5 3 Function Library Description 5 3 1 System Functions UTILIT
243. ram to exceed the size at 5 164 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library which fragmentation may occur which implies that the data portion of the datagram excluding headers should not exceed 512 bytes ADAM 4500 Series User s Manual 5 165 Chapter 5 Programming and Function Library 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 t he local and foreign hosts The select call may be used to determine when it is possible to send more data iFlags 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 DONTROUTE Specifies that the data should not be subject to routing MSG OOB Send out of band data SOCK STREAM only Out of band data See Also recv recvfrom socket send 5 166 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library setsockopt Syntax int setsockopt SOCKET so int evel int optname const char optval int optlen
244. ransi XTransft Get ACK for EOT 2 Click the Adam 4500 Configuration button to set IP address for TCP Client another ADAM 4500 Series Controller amp ADAM 4500 Series Utility Yer 1 14 18 xl File Help Local System Adam 4500 Series Configuration 0 01 01 12 00 00 PM 1 01 01 12 00 00 PM 0401701 12 00 00 PM 001701 12 00 00 PM 0401701 12 00 00 PM 1 01 01 12 00 00 PM 001701 12 00 00 PM 0401701 12 00 00 PM s UNO 3072 307 ewe lt MOBILE S D StaticIP C DHCP Address fia Jo Jo p Gateway M FTP amp HTTP Configuration FTP HTTP ID ID Password Password Rights Change Dir Rights Get Files l6 objects Creat Del Dir Post Files white File Use CGI Read File W System Initialization 4 System Files HTTPFTP Server FTP Server HTTP Server Go 4 58 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 3 Build TSERVER EXE from TSERVER PRJ under ADAM 4500 Series Utility Source Example TCP and download it onto drive D of the ADAM 4500 Series Controller which is the TCP server ADAM 4500 Series Utility Ver 1 14 12 x File Help ADAM 4500 Series IEEE Ez ret B 2 gi cow Sze Twe Modified CONF File Folder 2006 07 25 6 01
245. rary functions To make the most efficient use of ADAM 4500 Series Controller s memory space the ADAM 4500 Series function library has been separated into 10 smaller libraries Therefore a user can link only those libraries needed to run his application and only those libraries will be included in the compiled executable The smaller the linked libraries the smaller the compiled executable will be 5 1 1 Programming detail about the ADAM 4500 Series Controller The operating system of ADAM 4500 Series Controller is ROM DOS which is a MS DOS equivalent system It allows users to run application programs written in assembly language as well as high level languages such as C or C Certainly there will be some limitations when running application programs in the ADAM 4500 Series Controller In order to build successful applications please keep the following limitations and concerns in mind 5 1 2 Mini BIOS functions The ADAM 4500 Series Controller provides four serial communication ports including programming port for connecting peripherals so the mini BIOS of ADAM 4500 Series Controller only provides 10 function calls Since the users program cannot use other BIOS function calls the ADAM 4500 Series Controller may not work as intended Additionally certain language compilers such as QBASIC directly call BIOS functions that are not executable in ADAM 4500 Series Controller The ADAM 4500 Series Controller mini BIOS function cal
246. re RS 485 d Repeater 2 RS 232 Repeaters O 2 N ADAM IQ Miadul o Figure B 3 Random structure B 4 ADAM 4500 Series User s Manual Appendix B RS 485 Network B 2 Line Termination Each discontinuity in impedance causes reflections and distortion When an impedance discontinuity occurs in the transmission line the immediate effect is signal reflection This will lead to signal distortion Especially at line ends this mismatch causes problems To eliminate this discontinuity terminate the line with a resistor PROBE HERE Rt 120 Q Rt 470 posu d ee Rt 470 Q Figure B 4 Signal distortion The value of the resistor should be a close as possible to the characteristic impedance of the line Although receiver devices add some resistance to the whole of the transmission line normally it is sufficient to the resistor impedance should equal the characteristic impedance of the line Example Each input of the receivers has a nominal input impedance of 18k feeding into a diode transistor resistor biasing network that is equivalent to an 18 input resistor tied to a common k mode voltage of 24 V It is this configuration which provides the large common range of the receiver required for RS 485 systems ADAM 4500 Series User s Manual B 5 Appendix B RS 485 Figure B 5 Termination resistor locations Because each input is biased to 2 4 V the nominal commo
247. re greatly reduces the level of maintenance required and makes the ADAM 4500 Series Controller ideal for use in applications which required a high level of system stability ADAM 4500 Series User s Manual 1 5 Chapter 1 System Overview 1 2 6 Built in Ethernet Port The Ethernet port on ADAM 4500 Series Controller can perform powerful function as following FTP Server and Client Function Web Server Function Send Mail Function TCP and UDP Connection by Sockets 1 6 ADAM 4500 Series User s Manual Chapter 1 System Overview 1 3 ADAM 4501 4501D Controllers Specification 1 3 1 System e CPU 16 bit microprocessor e Memory 1 5MB Flash memory 256KB system Disk Drive C Read Only 256KB flash memory Accessed by Function LIB 1024KB file system 960KB for user applications Drive D Read Write 640KB SRAM up to 384KB with battery backup Accessed by Function LIB Operating System ROM DOS MS DOS 6 22 Compatible Real time Clock yes Watchdog Timer yes RS 232 interface COM1 RS 485 interface COM2 COM3 RS 232 485 interface Programming Port amp COM4 Select by jumper setting e LAN port x 1 10 100Base T e On board I O Capacity Digital Input 4 Channels Dry Contact Logic level 0 Close to GND Logic level 1 Open Wet Contact Logic level 0 2 V max Logic level 1 4 V 30 V Digital Output 4 Channels Open Collector to 40 V 200 mA maximum load 1 3 2 RS 232 interface COM1 e Sig
248. ries Utility Ver 1 13 File Help Local System ADAM 4500 Series m m Alafo z Name Size Type Modified f FTPD EXE 45KB Application 20060744 6 00 00 AM P HTTPD EXE 50KB Application 20060744 6 00 00 AM HrTPDEMO EXE 28KB Application 2006 07 14 6 01 00 AM y HTTPFTPD EXE B3KB Application 20060744 5 03 00 AM 30KB Application 44KB Application 45KB Application 50KB Application 28KB Application B3KB Application 1KB HTMLDo 7 object s 257 5 KB 4 object s 183 9 KB 627 200 bytes free Copyright c 1993 1996 Datalight Inc Datalight Patent Pending Resident Flash RFA OEM Layer z A start ayo iii Adam4500 S wh 6 21PM 3 Download WebAdam HTM onto drive D under Webroot directory ADAM 4500 Series Nam Size Type Modified P 4DAM EXE 30KB Application 20060744 6 02 00 AM FTPD EXE 45KB Application 20060744 6 00 00 AM HTTPD EXE SOKB Application 20060744 6 00 00 AM XIHTTPDEMO EXE 28KB Application 2006 07 14 6 01 00 AM P HTTPFTPD EXE 63KB Application 20060744 5 03 00 AM ADAM 30KB Application Fi 44KB Application ipa 45KB Application Ef httpd 50KB Application 7 uTTPDEMO 28KB Application hip tpa B3KB Application 1KB HTML Do THERE 7 object s 257 5 KB 5 objects 213 6 KB 596 480 bytes free Directory of D WEBROOT DIR 07 14 2006 Heal ay
249. riptor referencing the new socket Otherwise a value of INVALID SOCKET is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EAFNOSUPPORT The specified address family is not supported EMFILE No more file descriptors are available ENOBUFS No buffer space is available The socket cannot be created EPROTONOSUPPORT The specified protocol is not supported EPROTOTYPE The specified protocol is the wrong type for this socket ESOCKTNOSUPPORT The specified socket type is not supported in this address family Remarks 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 5 176 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Only a single protocol exists to support a particular socket type using a given address format However the address family may be given as AF UNSPEC unspecified in which case the protocol parameter must be specified 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
250. rsatile Protocols of Communication Function Libraries The communication protocol of the ADAM 4500 Series Controller is user defined and there are library functions of MODBUS RTU protocol and MODBUS TCP protocol available for users Of course users can implement ASCII based command and response protocol by themselves The function libraries include following protocols MODBUS RTU Master Function for connecting to remote I O modules via RS 485 port MODBUS RTU Slave Function for connecting to HMI SCADA software via RS 485 port MODBUS TCP Server Function for connecting to HMI SCADA software via Ethernet port MODBUS TCP Client Function for connecting to Ethernet enabled remote I O modules via Ethernet port 1 2 4 Built in ROM and RAM disk for programming The ADAM 4500 Series Controller has built in Flash Memory and SRAM for file downloading system operation and data storage It provides 1MB file system 960 KB free for users to download programs There are also 640KB SRAM to provide the memory needed for efficient application operation and file transfer Moreover users are allowed to decide the battery backup memory size up to 384KB in the SRAM 1 2 5 Built in real time clock and watchdog timer The micro controller also includes a real time clock and watchdog timer The real time clock records events while they occur The watchdog timer is designed to automatically reset the microprocessor if the system fails This featu
251. rver FTP Server HTTP Server Go C transi XTransft Get ACK for EOT 2 Click the Adam 4500 Configuration button to set IP address for Client another ADAM 4500 Series Controller S8 ADAM 4500 Series Utility Ver 1 14 18 xl File Help Local System Adam 4500 Series Configuratii m Adam 4500 S cigg r Sus onfiguration lt gt UNO 3072 307 lt MOBILE S D 001401 12 00 00 PM 1 01 01 12 00 00 PM 0401701 12 00 00 PM 001701 12 00 00 PM 0401701 12 00 00 PM 1 01 01 12 00 00 PM 001701 12 00 00 PM 0401701 12 00 00 PM StaticIP C DHCP Address fia Jo Jo aE Gateway address automatically por TI Update Shared Docu My Document r FTP amp HTTP Configuration FTP HTTP ID ID Password Password Rights Change Dir Rights Get Files l6 objects Creat Del Dir Post Files white File Use CGI Read File mt System Initialization 4 System Files HTTPFTP Server FTP Server HTTP Server Go 4 72 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 3 4500 Build USERVER EXE from USERVER PRJ under ADAM Series Utility Source Example TCP and download it onto drive D of the ADAM 4500 Series Controller which is the UDP server
252. s free Write Image 7 object s 0 byte s Estimate time Bminutes Restore Image Directory of D N CONF DIR 06 19 2006 6 29p WEBROOT lt DIR gt 06 19 2006 6 29p AUTORUN BAT 128 06 19 2006 6 29p AX87965 COM 13 312 06 19 2006 6 29p CFGIO EXE 35 328 06 19 2006 6 29p SOCKETP EXE 48 896 06 19 2006 6 30p REID EXE 6 528 06 19 2006 6 31p 7 file s 104 192 bytes 700 928 bytes free A start eu iii Adam4500 Download 10 Click the or files from host 4500 Series PC on button for the left Controller on the right window fill ADAM 4500 Series Utility er 1 13 File Help E mS 6 48PM downloading programs window to ADAM Local System O webRoot E dhcpstat Ef httpget Ei stat EJ ipstat F IMAKEMAIL E sENDMaIL ES ping File Folder Application Application Application Application Application Application Af File transfer ADAM 4500 Series 2006 1 2004 1 WM AUTORUN BAT 1KB PW Ax8796 COM 13KB FE CFGIO EXE 35KB 7KB Z REID EXE SOCKETP EXE 48KB File Folder File Folder MS DOS B MS DOS A Application Application Application la object s 175 0 KB BAT COM Transferring File count Progress 171 C Program Files amp amp dvantech amp DAM 4500 Series Utility S or BHHHRH i re m valcom 2006 0649 6 02 00 AM 2006 0649 6 02 00 4M 2006 0649 6 02 0
253. s of HTTP server and COGI function Mail Example of sending mail function ModbusRTU Modbus RTU examples ModbusTCP Modbus TCP examples TCP Examples of TCP and UDP connections INC AIL related headfile Library Function Libraries S01 Lib Basic function libraries http Lib HTTP function libraries MModRTU_Lib Modbus KTU libraries Mod IUP Lib Modbus TCP libraries sockets_Lib socket libraries ADAM 4500 Series User s Manual 3 5 Chapter 3 Program Download 3 3 ADAM 4500 Series Utility Overview 1 Put switch into Initial mode and then reboot Initial mode is for configuration and download program into ADAM 4501 controller Always set Initial mode when downloading program Normal mode will automatically run the downloaded program in the autorun bat file when ADAM 4500 Series Controller boots up Refer to section 3 6 for more detail 2 Execute Adam4500 exe under C Program Files Advantech ADAM 4500 Series Utility Program Select the COM Port on your PC which you use to connect to ADAM 4500 Series Controller i ADAM 4500 Series Utility Ver 1 13 File Help Local System ___ADAM 4500 Series n b D 0 le 0 0 B f ono B EEE Te My Computer T Modified s LINO 3072 3074 Local Disk s Removable Disk Removabl s Removable Disk Removabl a ADY SRAMDRY Removabl B Control Panel System Fol 3 Shared Documents File Folder 3 1 2006 9 E My Docume
254. scription ucPort The Port number you want to initial see remarks Return value If success return O If fail returns a negative number as follows COM already installed 1 Err Access COM 2 No Such Port 3 Remarks Parameter Value Description COM COM i ucPon COM2 COM2 COM3 COM3 COM4 COMA ADAM 4500 Series User s Manual 5 39 Chapter 5 Programming and Function Library SIO Close Syntax CHAR SIO Close UCHAR i ucPort Description Release resource of the specific COM port If a user calls the SIO Open function the user must call this function to release the COM port before the user s program terminates Parameter Description ucPort The Port number you want to release see remarks Return value If success return O If fail returns a negative number as follows No Such Port 3 Remarks Parameter Value Description COM1 COM1 I COM2 COM2 ucPort COM3 COM3 5 40 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO SetState Syntax CHAR SIO SetState UCHAR i ucPort ULONG i ulBaudRate UCHAR i ucParity UCHAR i ucDataBits UCHAR i ucStopBits Description Sets the parameters such as baud rate parity data bits and stop bits for the specific COM port Parameter Description ucPort The Port number you want to use see remarks i ulBaudRate The Baud Rate number you want to set up ucParity The Parity you want to set up see remarks u
255. sed to get the last error Example please refer the examples under C Program Files Advantech ADAM 4500 Series Utility Source Example ModbusAppEx ADAM 4500 Series User s Manual 5 99 Chapter 5 Programming and Function Library ADAMTCP ReadCoilStatus Syntax int ADAMTCP_ReadCoilStatus SOCKET SO int WaitMilliSec int Slave Addr int Startlndex int TotalPoint int ByteCount char wData Description 01 HEX command of Modbus TCP function code Parameter Desceription SO The socket connected to Modbus TCP server WaitMiliSec Set duration msec for the response from Modbus TCP server Slave Adadr Slave address StartIndex Starting address TotalPoint No of points ByteCount Byte count wData Data Return value TRUE No error occurs 0 Time out error when receive modbus query message from Modbus TCP server 1 Error occurs when send modbus query message to Modbus TCP server 2 Error occurs when receive modbus query message from Modbus TCP server Example I ADAMTCP ReadCoilStatus amp SO 4500 50 0x01 0x11 0x10 amp DataByteCount HostData lt 0 perror ADAMTCP_ReadCoilStatus n ADAMTCP_Disconnect amp SO_ 4500 return 0 else adv printf Adam 4500 Status for tmp 0 tmp lt DataByteCount tmp adv_printf 2X HostData tmp 5 100 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library adv_printf n ADAM 4500 Series User s Manual 5 101
256. series Ethernet Controller Whenever users open the IE Browser to acquire data from ADAM 4500 series controller through Internet or Intranet it will call up the existed web pages to provide a monitor and control portal All of the commands from the web page must be linked via a CGI program to the C control program which handle the real read write action in I O channels HTML Web Page monitor and control portal HTTP Ethernet CGI Common Gateway Interface Program Server Jr Jr C Program for Local l O Module Handling ADAM 4500 Series Controller Basically there are three steps in the process of Web Monitoring amp Control 1 Registration Register a HTML name for the web page you designed 2 User login and invoke control program After registration users can invoke local control program by login Server 3 Local I O activated by local control program 4 14 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions HTTPDEMO C Zinclude lt stdio h gt Zinclude stdlib h Zinclude lt string h gt include lt process h gt include 4500drv h include CGI Lib h FILE fp int number 0 int count l void ReplaceStr char ptr_strl char ptr_str2 int len str void main void char homepage name index htm if Http Server Reg homepage name return printf Program exiting HttpDeRegister index htm j int far Callback HTTP_PARAMS far psParams im
257. socket has been connected with connect or accept A SOCKETS application must not assume that the IP address will be changed from INADDR ANY unless the socket is connected This is because for a multi homed host the IP address that will be used for the socket is unknown unless the socket is connected See Also bind socket getpeername ADAM 4500 Series User s Manual 5 133 Chapter 5 Programming and Function Library getsockopt Syntax int getsockopt SOCKET so int iLevel int Optname char pcOptval int piOptlen Description Retrieves a socket option Parameters Description SO A descriptor identifying a socket iLevel The level at which the option is defined the only supported levels are SOL SOCKET andIPPROTO TCP iOptname The socket option for which the value is to be retrieved pcOptval A pointer to the buffer in which the value for the requested option is to be returned piOptlen A pointer to the size of the pcOptval buffer Return Value If no error occurs getsockopt returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EFAULT The piOptlen argument was invalid ENOPROTOOPT The option is unknown or unsupported In particular SO BROADCAST is not supported on sockets of type SOCK STREAM while SO ACCEPTCONN SO DONTLINGER SO KEEPALIVE SO LINGER and
258. ss sajnpoy uonisinboay geq Losr nvayv Spry 39u19433 Figure 2 6 Dry contact wiring for DI channel 2 6 ADAM 4500 Series User s Manual Chapter 2 Installation Guidelines sa npojy uonisinbay ejeq LOGt INVOV jou19u33 Figure 2 7 Wet contact wiring for DI channel Load 40 VDC Max sa npojy uonisinboy geq LOGt INVOV Spry 39u19u33 Figure 2 8 Digital output wiring ADAM 4500 Series User s Manual 2 7 Chapter 2 Installation 2 3 3 System Network Connection Network Connection for System Configuration and Download The ADAM 4500 Series Controller has a Programming port This port COMA allows you to program configure and troubleshoot the ADAM 4500 Series Controller from your host computer The Programming port has an RS 232 interface and only uses TX RX and GND signals The cable connection and the pin assignment are as follows 7 Covent Te t i a x ae Data Acgasilias Bipi a hja b DU fy 4 Th S i LT i I H E an RS 232 ADAM 4500 series PC COM port straight through cable Prog port CD 1 RX 2 TX TX 3 RX DTR 4 GND 5 GND DSR 6 RTs 7 8 9 Figure 2 9 System Configuration Wiring 2 8 ADAM 4500 Series User s Manual Chapter 2 Installation Guidelines Note We also provide a friendly cable for Programming port wiring Please refer following pictures to wire the Programming port Figure 2 10 Cable C
259. ss BASE COMI is 3F8h and COM2 is 2F8h DLAB is the Divisor Latch Access Bit bit 7 of BASE 3 BASE 0 Receiver buffer register when DLAB 0 and the operation is a read BASE 0 Transmitter holding register when DLAB 0 and the operation is write BASE 0 Divisor latch bits 0 7 when DLAB 1 BASE 1 Divisor latch bits 8 15 when DLAB 1 Bytes BASE 0 and BASE 1 together form a 16 bit number the divisor which determines the baud rate Set the divisor as follows Baud rate Divisor Baud rate Divisor 50 2304 2400 48 75 1536 3600 32 110 1047 4800 24 199 5 857 7200 16 150 768 9600 12 300 384 19200 6 600 192 38400 3 1200 96 56000 2 1800 64 115200 1 2000 58 X X A 2 ADAM 4500 Series User s Manual BASE 1 BASE 2 Appendix A COM Port Register Structure Interrupt Status Register ISR when DLAB 0 bit 0 Enable received data available interrupt bit 1 Enable transmitter holding register empty interrupt bit 2 Enable receiver line status interrupt bit 3 Enable modem status interrupt FIFO Control Register FCR bit 0 Enable transmit and receive FIFOs bit 1 Clear contents of receive FIFO bit 2 Clear contents of transmit FIFO bits 6 7 Set trigger level for receiver FIFO interrupt Bit 7 Bit 6 FIFO trigger level 0 0 01 0 1 04 1 0 08 1 1 14 BASE 3 Line Control Register LCR bit 0 Word length select bit 0 bit 1 Word length select bit
260. st To Send and CTS Clear To Send are the most commonly used methods Host command Module reply Pm qr Figure B 6 HS 485 data flow control with RTS Intelligent RS 485 Control ADAM 4510 and ADAM 4520 are both equipped with an I O circuit which can automatically sense the direction of the data flow No handshaking with the host like RTS Request to Send is necessary to receive data and forward it in the correct direction You can use any software written for half duplex RS 232 with an ADAM network without modification The RS 485 control is completely transparent to the user ADAM 4500 Series User s Manual B 7 Appendix C Grounding Reference Appendix C Grounding Reference Field Grounding and Shielding Application Overview Unfortunately its impossible to finish a system integration task at one time We always meet some trouble in the field A communication network or system isnt stable induced noise or equipment is damaged or there are storms However the most usual issue is just simply improper wiring ie grounding and shielding You know the 80 20 rule in our life we spend 20 time for 80 work but 80 time for the last 20 of the work So is it with system integration we pay 20 for Wire Cable and 0 for Equipment However 80 of reliability depends on Grounding and Shielding In other words we need to invest more in that 20 and work on these two issues to make a highly reliable system This application
261. t n Suppress progress indicator V Verbose output for troubleshooting o Port Connect to a server port other than the standard FTP port number of 21 f ScriptFile A file containing commands for the client to send to the server upon connection Simple parameter substitution is performed with the first element of ScriptParameters accessible as 1 etc ScriptParameters Parameters to pass into the ScriptFile Return Codes 0 Success 1 Parameter error 2 SOCKETS not loaded 3 User aborted 4 Transfer aborted 5 Error writing local file 6 Error reading local file Other Server returned error response code to find that error code add 390 to the response code returned by FTP The result will always be greater than or equal to 400 in this case 6 4 ADAM 4500 Series User s Manual Chapter 6 Sockets Utility Example FTP n FTP cdrom com f getfile scr 2 simtelnet msdos DIRS TXT The file GETFILE SCR user anonymous pass root cd 961 binary get 962 quit FTP Commands The commands entered at the FTP client can be interpreted and translated to standard FTP commands to be sent to the server The FIP server might recognize more or less commands than the standard list of commands as specified in RFC 959 The site command is always server dependent Some of the standard commands are implemented differently in various servers Useful things to note are 1 The put and get commands allow multiple fil
262. t is small enough to fit into available memory Since HTTPD is blocked while the CGI program executes user interaction should not be used and the CGI program should complete in a reasonable time Operation on receiving a CGI URL If the CGI program name is followed by a the rest of the line is sent as a command line to the CGI program after converting all n combinations If a Content Type header IS encountered the CONTENT TYPE environment variable is set to the given value and if a Content Length header is encountered the CONTENT LENGTH environment variable is set to the given value The PATH and COMSPEC environment variables are copied to the new environment and the REQUEST METHOD environment variable is set to either GET or POST If the POST method is used the rest of the HTTP message is copied ADAM 4500 Series User s Manual 5 193 Chapter 5 Programming and Function Library to a temporary file that is then re directed to stdin The stdout stream is redirected to another temporary file After completion of the request the temporary files are deleted They will be created in the HTTPTMP directory 5 194 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library The CGI program is now invoked This program can check the environment variables access the command line and in the case of a POST read from stdin All output that should be passed back to the HTTP client Browser is written
263. t file directory mkd remote directory nist file directory pass password pasv on off retr remote file stor ocal file pwd quit rmd remote directory rnfr existing filename 2 rnto new filename 2 site path nopath site raw interface site sub command size file stat system type i I a user username the file exists change server directory delete a server file give a long directory listing create a server directory gives a short names only directory listing password for username report or change the status of the passive transfer mode to enable firewall friendly file transfers The SOCKETS FTP client always tries to switch passive mode on at the start of a session transfer a file from the server in the current mode transfer a file to the server in the current mode print working directory terminate FTP session remove delete directory rename a file command 1 of rename a file command 2 of use full path description open a session to a raw host using one of the raw lines interfaces specified command to be passed on to raw host report the file size in bytes as a message prefixed with 213 report the status of a Or X active connections return operating system information from the server report or select the file transfer mode image binary or ASCII username to logon transfer ADAM 4500 Series User s Manual 7 13 Chapter 7 HTTP and FTP Server Application Combined HTTP and FTP Ser
264. t html gt 4 24 ADAM 4500 Series User s Manual Chapter 4 Guidelines for Network Functions 4 3 Send Mail Example program AMAIL EXE MAIL TXT Source file ALARMMAIL C under ADAM 4500 Series Utility Source Example mail directory Utility SENDMAIL EXE MAKEMAIL EXE ADAM 4500 series configuration 1 Right click on the right window and choose Make Directory Put switch into Initial mode Ir Fx 5 1 curat Fo In Cour D IE Dp T JT PEC f poke a T fautor B wib sid UB Anphoss TT Een cow uit ul Eyre p ihig EIE Eppie y TS MAR i int D E PE coc eee AB App w rj B Appia mu ir AH Applicat mr 5 W Appii ST Pte Miaka Dee e TET aperi ia B obasja ILE amp obiecti LXI s Pee P Pdiiein byien 575 45 byies Bie a BAIL di exi hiir Volume im drive D has mo label Volume Sorial Humakerr s JA amp E 12 Daretexry af Doc CONT nike amp T i4 2b b 113a FEHR T IDIR PF 1000 Lik Wie AUTORUH HAT i28 b i8 200 amp ij Ota oot Pde bo D 13 317 67 14 200 amp 11 te cpero ERE 15 338 amp 7 i4 2b06 if H4a GEETA EE 10 896 57 15 2006 1b tte i tidied a7 264 brio 575 558 brie ree 2 Type Mail to name the directory and click on the OK button This directory is for download related executives and files later miror AD emen amp m mje elel wa mg a a Dez Ir Fam Fle h t E LT few ce wan Fie Fodder OLTE T1 OCEDD Al I1 Fok
265. t 22KB Application 4 13 BcFcio EXE 35KB Application 2006 07 03 4 02 00 AM EI MAKEMAIL 28KB Application 4 13 DHCPSTAT EXE 19KB Application 2006 07 03 4 03 00 AM 1 SENDMAIL 24KB Application 4 1372 REID EXE 7KB Application 2006 07 03 4 02 00 AM Ef sping 20KB Application 4 13 2 SOCKETP EXE 48KB Application 2006 07 03 4 02 00 AM 8 object s 175 0 KB l8 object s 120 6 KB 683 008 bytes free 07 03 2006 4 WEBROOT lt DIR gt 07 03 2006 4 24p AUTORUN BAT 142 07 03 2006 4 30p AX8796 COM 13 312 07 03 2006 4 24p CFGIO EXE 35 328 07 03 2006 4 24p SOCKETP EXE 48 896 07 03 2006 4 24p REID XE 6 528 07 03 2006 4 27p DHCPSTAT EXE 19 328 07 03 2006 4 30p 8 file s 123 534 bytes 683 008 bytes free A start ey ilii Adam4500 wm 9 06 AM 6 2 ADAM 4500 Series User s Manual Chapter 6 Sockets Utility DHCPSTAT DHCPSTAT displays the DHCP information for the machine Syntax DHCPSTAT r v Options r force a renewal of the DHCP lease V display the SOCKETS version information Example DHCPSTAT X This will display all the DHCP information such as IP address and lease time ADAM 4500 Series User s Manual 6 3 Chapter 6 Sockets Utility FTP FTP is a file transmitting and retrieving client that runs in interactive or batch mode Syntax FTP server options Options n IN p Port f ScriptFile ScriptParameters Remarks Server The name or IP address of a server you want to connec
266. t s Programming port 3 ADAM 4500 Series Controller TCP Client Ethernet Port Download program Ethernet TCP IP ADAM 4500 Series Controller TCP Server This example uses one ADAM 4500 Series Controller as TCP client to connect to another ADAM 4500 Series Controller as TCP server They can exchange data between each other through TCP IP communication Chapter 4 Guidelines for Network Functions 1 Put switch of the two ADAM 4500 Series Controllers into Initial mode Click the Adam 4500 Configuration button to set IP address for TCP Server ADAM 4500 Series Controller ADAM 4500 Series Utility Ver 1 14 J l x File Help i Local System s LINO 3072 3 s MOBILE S D D6 07 25 5 04 00 AM 6 07 25 5 04 00 AM DI6 07 25 5 04 00 AM 6 07 25 5 04 00 AM D6 07 25 5 04 00 AM 6 07 25 5 05 00 AM 6 07 25 5 04 00 AM 6 07 25 6 00 00 AM Ae INS address automatically Address o No No H2 Gateway sf 34 Ff B My Documen Update r FTP amp HTTP Configuration FIP HTTP ID ID Password Password Rights Change Dir Rights 7 Get Files l objec s Creat Del Dir Post Files Write File Use CGI Read File Update M System Initialization v System Files HTTPFTP Server FTP Server HTTP Server Go C t
267. te that the stack and the data segment on entry will be that of HTTPD Depending on the memory model used for the extension and the amount of stack space required it may be required to switch stacks during the callback 5 202 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library HttpDeRegister Syntax int HttpDeRegister char far pszPath Description The HttpDeRegister function removes the interest in a URL After this call no more callbacks will be generated for this URL Any requests in progress will be terminated with an error to the peer This function must be called for all registrations made by a program before terminating that program otherwise the system will inevitably crash on any subsequent request Parameters Description pszPath Far pointer to URL to de register Return value 0 OK lt 0 One of the error messages SEE HTAPIC H Low level calling parameters AH APIF_DEREGISTER 1 DS SI pszPath Low level return parameters Return code in AX ADAM 4500 Series User s Manual 5 203 Chapter 5 Programming and Function Library HttpGetData Syntax int HttpGetData int Handle char far pcBuf int Count Description The HttpGetData function can be called when a POST operation has been indicated by the callback to get data sent to the server by the client If more data is expected and the extension is busy executing the callback function a O return should be made from the callback in
268. tected the RCS sends the changed data to the Java applet Keyboard data received from the client is passed to the keyboard buffer making it available as keyboard input for use by any application executing on the server ADAM 4500 Series User s Manual 7 3 Chapter 7 HTTP and FTP Server Application Remote Console Client The remote console client exists as a Java 1 3 1 applet supplied as RC JAR and will function on any Java 1 3 1 compliant browser Please note that a security certificate has _ not been compiled into RC JAR so it is not compliant with versions of the Netscape browser that require a security certificate to run Java applets A DOS based client using SOCKETS is also supplied as RCCLI EXE For additional information about RC JAR Or RCCLI EXE please see the Utility Description Chapter Extension CGI The SOCKETS HTTP servers HTTPD HTTPFTPD provide a facility to call functions in other modules which may be TSR or transient programs These functions are referred to as HTTPD extensions For more information please see the ROM DOS Developer s Guide section CGI Application API Extension CGI Examples Five very simple examples are included to demonstrate the implementation of CGI Source code is included Put all htm and exe files in the HITP_DIR directory and start HTTPD Load all the cgi programs you may use cgi bat All is in place now and the examples may be accessed through index htm The f
269. ter The latter is constructed by or ing any of the following values Value Meaning MSG _ PEEK Peek at the incoming data The data is copied into the buffer but is not removed from the input queue MSG_OOB Process out of band data See Also recvfrom recv send select socket 5 152 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library recvfrom Syntax int recvfrom SOCKET so char pcBuf int iLen int iF ags struct sockaddr psFrom int piFromlen Description Receives a datagram and store the source address Parameters Description SO A descriptor identifying a bound socket pcBuf A buffer for the incoming data iLen The length of pcBuf iFlags opecifies the way in which the call is made psFrom An optional pointer to a buffer which will hold the source address upon return piFromlen An optional pointer to the size of the psFrom buffer Return Value If no error occurs recvfrom returns the number of bytes received If the connection has been closed it returns 0 Otherwise a value of SOCKET ERROR is returned and a specific error code is returned in errno Error Codes ENETDOWN SOCKETS has detected that the network subsystem has failed EFAULT The piFromlen argument was invalid the psFrom buffer was too small to accommodate the peer address EINVAL The socket has not been bound with bind ENOTCONN The Socket IS not connected SOCK_STREAM only ENOTSOCK T
270. tes free Volume Serial Number is 3D46 1AE0 Directory of D N CONF lt DIR gt 06 19 2006 lp WEBROOT lt DIR gt 06 19 2006 Za Lip AUTORUN BAT 128 06 19 2006 7 1ip AX8796 COM 137312805 19 a 7 11p CFGIO EXE 39 320 06 1922006 crim SOCKETP EXE 48 896 06 19 2006 aba 6 file s 97 664 bytes 751 616 bytes free A start ey au Adam4500 s wy WE C 7 23PM The FTP and HTTP Server file is under WEBROOT directory HIT ADAM 4500 Series Utility Ver 1 13 File Help 18 x Local System ADAM 4500 Series O w ebRoot File Folder 2006 1 Ef dhcpstat 19KB Application 2004 1 httpget 39KB Application 2004 1 ista 25KB Application 2004 1 E ipstat 22KB Application 2004 1 IMAKEMAIL 28KB Application 2004 1 EEISENDMAIL 24KB Application 2004 1 Ef sping 20KB Application 2004 1 B3KB Application 20060619 7 01 00 AM B object s 175 0 KB 1 object s 62 8 KB 751 616 bytes free Volume in drive D has no label Volume Serial Number is 3D46 1AE0 Directory of D WEBROOT DIR 06 19 2006 7 11p ac lt DIR gt 06 19 2006 7 11p HITPFTPD EXE 64 256 06 19 2006 He UZD 3 file s 64 256 bytes 751 616 bytes free start ayoo iii Adam4500 3 14 ADAM 4500 Series User s Manual Jj wy wi C 7 24PM Chapter 3 Program Download 3 5 Configure IP address and ftp http user password settings Following steps wil show you how to configure IP address and
271. the size of a struct sockaddr EAFNOSUPPORT The specified address family is not supported by this protocol EINVAL The socket is already bound to an address ENOBUFS Not enough buffers available too many connections ENOTSOCK The descriptor is not a socket 5 124 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Remarks 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 socket address assigned bind establishes the local association host address port number of the socket by assigning a local address to an unnamed socket In the Internet address family an address consists of several components For SOCK_DGRAM and SOCK_STREAM the address 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 application programming in the presence of multihomed hosts If the port is specified as 0 SOCKETS will assign a unique port to the application The application may use getsockname after bind to lear
272. to listen on This parameter defaults to the standard HTTP port number of 80 rc port Remote Console port to listen on This parameter defaults to 81 The root directory for web content is the current directory when HTTPD is started This can be changed by setting an environment variable HTTP DIR e g SET HTTP DIRZDASERVERWEB Format of SOCKET UPW This is the same file used for the HTTP and FTP server s FTPD EXE permissions This file consists of lines where each line contains a users information A line starting with a is considered a comment and is ignored Each line consists of four fields Username Password Working Directory gt Permissions comment of Username The name of this user If it is it will be used when the client does not specify a username Password This users password If it is no password is required Working Directory The user will only have access to this directory and its subdirectories If it is f this user has access to the whole system HTTP DIR can be referred to as If a relative path is specified it is appended to HTTP DIR Permissions When a user is granted both FIP and HTTP permissions the FIP permissions must appear first otherwise they will be ignored Permission are listed below FTP Rights d change directories C create delete directories Ww write files 7 8 ADAM 4500 Series User s Manual Chapter 7 HTTP and FTP Server Applicatio
273. turer Parameter Description ucPort The Port number you want to use i ucCmdStr opecifies command string please refer to the AT command document Return value If success return O If fail return a negative number as follows Illegal Setting b Remarks COM COMI ADAM 4500 Series User s Manual 5 59 Chapter 5 Programming and Function Library SIO ModemCommand State Syntax CHAR SIO ModemCommand State UCHAR i ucPort Description Sets modem to command mode In other words this causes the modem to escape from data mode to command mode The modem will delay at least 3 seconds before switching back to command mode This command has the same effect as sending the ASCII command to the modem Parameter Description ucPort The Port number you want to use see remarks Return value If success return O If fail return a negative number as follows Illegal Setting 5 Remarks 5 60 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library SIO ModembDial Syntax CHAR SIO_ModemDial UCHAR i ucPort UCHAR i ucTelenum Description Directs modem to connect to the specified telephone number Parameter Description ucPort The Port number you want to use see remarks i ucTelenum The phone number you would like modem to dial Return value If success return O If fail return a negative number as follows Illegal Setting 5 Remarks COMI COMI ADAM 4500 Series User s Manual 5
274. ual Chapter 3 Program Download 5 You will find the initialization process IS peronng fil ADAM 4500 Series Utility Yer 1 13 81 xj File Help Local System ADAM 4500 Series B cu i E Cu xal a m a cow z ee reeves eee eo Adam 4500 Series Configuration E Name Adam 4500 Series System Conf amp Init O w ebRoot System Configuration dhepstat IP DHCP E httpget StaticIP cC DHCP Obtain DNS address automatically Elisa Addes 1 I Pima DNS I T File transfer l ipstat File transfer MAKEMAIL FRISENDMAIL ES ping 02 00 AM 02 00 AM 02 00 AM 02 00 AM 02 00 AM 04 00 AM Gatew Transferring C Program Files Advantech ADAM 4500 Series Utility Sor File count 1 4 Progress Write File Read File C N transfer lt lt Transferrin A start ey iii Adam4500 Wi wa V 7 22PM 6 Click the OK button to finish the initialization process II ADAM 4500 Series Utility Yer 1 13 EE lej xj File Help ADAM 4500 Series IB aco Local System Adam 4500 Series System Conf amp Init System Configuration dhcps tat IP DHCP httpget Static IP DHCP Obtain DNS address automatically d stat Address Primary DNS ipstat Update 02 00 AM 02 00 AM 02 00 AM 02 00 AM 02 00 AM 04 00 AM 0 3 00 AM 03 00 AM
275. ulArgp l if ioctlsocket Sock 4500 FIONBIO amp pulArgp perror ioctlsocket exit I j if listen Sock_4500 5 SOCKET_ERROR perror listen exit I j hasMessage FALSE memset WaitSocketCount 0 sizeof WaitSocketCount printf Server started wait for connect n while 1 if socketTotal gt 0 hasConnect Host WaitForClient Sock 4500 0 else hasConnect Host WaitForClient Sock 4500 5 ADAM 4500 Series User s Manual 4 63 Chapter 4 Guidelines for Network Functions if hasConnect printf Receive client connect request n sin size sizeof struct sockaddr in if New Conn accept Sock 4500 struct sockaddr amp Client addr amp sin_size INVALID SOCKET f perror accept continue j if New_Conn INVALID_SOCKET if socketTotal lt Max Conn remoteSocket socketTotal New Conn New Sidx socketTotal socketTotal 4 else if send New_Conn Connetion full you are going to be disconnected u 50 0 SOCKET ERROR perror send closesocket New Conn printf Connetion full disconnect client u j j else printf TCP Invalid incoming socketNn str Hello world n if send remoteSocket New_Sidx str strlen str 0 SOCKET ERROR perror send j if socketTotal gt 0 for sidx 0 sidx lt socketTotal sidx hasMessage Host_WaitForClient remoteSocket sidx 0
276. under root directory Put switch into Initial mode from DEMORC PRJ under E laxi File Help Local System ADAM 4500 Series s dm eu cov z C Program Files Advantechi 4D4M 4500 Series LltilityYSo h T Name Size Type Modfiec Name smeje Modified 4500DRV H 12KB H File 2 22 20 CONF File Folder 1980 01 01 12 00 00 PM DemoRC c 1KB CFile 2 23 20 WEBROOT File Folder 1980 01 01 12 00 00 PM DEMORC EXE 23KB Application 7725 20 amp uroRUN BAT 1KB MS DOSB 1980 01 01 12 00 00 PM s DemoRC PRJ 5KB PRU File 7 25 2C 7 4x8786 coM 13KB MS DOS A 1980 01 01 12 00 00 PM DemoRS c 1KB CFile 7424 20 CFGIO EXE 35KB Application 1980 01 01 12 00 00 PM DEMORS DSK 3KB DSK File 7425 20 luit DEMORC EXE 23KB Application 1980 01 01 12 00 00 PM DEMORS EXE 41KB Application 7 25 2C DEMOTC EXE 48KB Application 1980 01 01 12 01 00 PM E DemoRS PAJ 5KB PAJ File 7 25 2C SOCKETP EXE 48KB Application 1980 01 01 12 00 00 PM DemoTC c 3KB C File 6 21 20 DEMOTC EXE 48KB Application 7 25 2C si DemoTC PRJ 5KB PRA File 7725 20 DemoTS c 2KB C File 7 24 20 si DEMOTS DSK 3KB DSK File 7 18 20 NEMOTS FXF FIKR nnlcatian zonaz 17 object s 230 0 KB 8 object s 164 6 KB 679 936 bytes free CardTrick v3 01 00 Copyright c 1993 1996 Datalight Inc Datalight Patent Pending Resident Flash RFA OEM Layer Drive s D 789 C
277. 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 the excess data is lost and recvfrom returns the error code EMSGSIZE If psFrom is non zero and the socket is of type SOCK DGRAM the network address of the peer which sent t he data is copied to the corresponding struct sockaddr The value pointed to by piFromlen 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 waits for data to arrive unless the socket is non blocking In this case a value of SOCKET ERROR is returned with the error code set to EWOULDBLOCK The select call 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 a recvfrom will complete immediately with O bytes received If the connection has been reset recv will fail with the error FCONNRESET gt ADAM 4500 Series User s Manual 5 155 Chapter 5 Programming and Function Library iFlags 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 aredetermined by the socket options and the iF ags parameter The latter is constructed by or ing any of the following values Va
278. urity SRAM supports 113 bytes for user storage of important information Parameter Description which_byte From 0 to 112 user determined data Value to be saved Return value Get_SysMem Get the value in a byte of security SRAM Set_SysMem None Example include 4500drv h void main void unsigned char data 4 1 2 3 4 int i save current value for i210 i lt 145i Set SysMemy i data i 10 adv_printf data d n Get_SysMem i Remarks None ADAM 4500 Series User s Manual 5 21 Chapter 5 Programming and Function Library Get NVRAM Size Set NVRAM Size Syntax unsigned char Get NVRAM Size void void Set NVRAM Size unsigned char sector Description Get NVRAM Size Gets the size of battery backup RAM oet NVRAM Size Sets the size of battery backup RAM The unit is sectors each sector is 4KB in size Maximum size is 384 KB theoretically Parameter Description sector NVRAM size in 4 KB sectors from 1 to 96 sectors Return value Get NVRAM Size sector Number of sectors NVRAM size is set to from 1 to 96 Set NVRAM Size None Example include 4500drv h void main unsigned char sector sector Get NVRAM Size adv printf Backup ram dKbyte n sector 4 Set Bacup ram 40Kbyte Set NVRAM Size 10 j Remarks None 5 22 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library write backup ram read backup ram Syntax void
279. users password of FIP server and HTTP server for ADAM 4500 Series Controller Please note the default IP address is 10 0 0 1 1 Put switch into Initial mode and then reboot 2 Click the Adam 4500 Configuration button 18 xl Modified Se UNO 3072 3074 Local Disk s Removable Disk Removabl ss Removable Disk Removabl a SDY SRAMDAY Removabl J Control Panel System Fol Shared Documents File Folder 3 1 2006 3 My Documents File Folder 6 16 2006 CONF File Folder 200606416 1 00 00 AM C WwEBROOT File Folder 2006 0616 1 00 00 AM fs AUTORUN BAT 1KB MS DOSB 2006 0646 1 00 00 AM 7 4x8786 cOM 13KB MS DOS A 2006 05 16 1 00 00 AM CFGIO EXE 35KB Application 2006 0646 1 00 00 AM SOCKETP EXE 48KB Application 200690646 1 00 00 AM 7 object s 0 byte s 6 object s 05 2 KB 751 616 bytes free Volume Serial Number is 314E 08D7 Directory of D N CONF DIR 06 16 2006 1 02a WEBROOT lt DIR gt 06 16 2006 1 02a AUTORUN BAT 128 06 16 2006 1 02a AX8796 COM 13 184 06 16 2006 1 02a CFGIO EXE 35 328 06 16 2006 1 02a SOCKETP EXE 48 896 06 16 2006 1 02a 6 file s 97 536 bytes 751 616 bytes free pu start S 2 W radamssoo LATET ADAM 4500 Series User s Manual 3 15 3 Chapter 3 Program Download Select Static IP and fill in the IP address and Gateway IP Select Obtain DNS address automatically Click the Up
280. ut your code in Here j WDT disable j Remarks None 5 28 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library display init display digit Syntax void display inti unsigned char decode mode int display digit unsigned char data unsigned char digit unsigned char len Description 7 segment display setting Display init Initialize all 7 segment displays Display digit Writes the numeric into the all 7 segment displays Parameter Description decode mode Decode mode 0 is No decode 1 is Code B decode data The display value digit There are five segment LED displays This parameter determines which display is the starting LED display It can be 1 5 len Total number of LED diplays you want to control No Decode mode STANDARD 7 SEGMENT LED REGISTER DATA AEH REN DET COS RES EH Oy Corresponding a segment Line lajsfefofe ele The bit DO D7 are the corresponding LED segment For example data 30 hex can show the 1 of the LED character D5 D4 are 1 and others are 0 ADAM 4500 Series User s Manual 5 29 Chapter 5 Programming and Function Library Code B Decode mode REGISTERDAA DATA ON SEGMENTS 1 7 SEGMENT x x lt J e lt EEBE ETETEA E a ee es p gt EE EB E EZEN ECNENECERS EN NN EON ENEA EA EE e T a M
281. v printf init success n 5 74 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library Modbus COM Release Syntax void Modbus_COM_Release int Port Description Release the COM port of Modbus connection Parameters Value Description Port 1 COM 1 2 COM2 3 COM3 4 COM4 Return value None ADAM 4500 Series User s Manual 5 75 Chapter 5 Programming and Function Library Error Code Syntax int Error Code void Description When following function call gets error return this function can get the exact error code for user ADAMRTU ForceMultiCoils ADAMRTU ForceSingleCoil ADAMRTU PresetMultiRegs ADAMRTU PresetSingleReg ADAMRTU_ReadCoilStatus ADAMRTU_ReadHoldingRegs ADAMRTU ReadlnputRegs ADAMRTU ReadinputStatus Parameters None Return value NULL No exception error returned Erro Code Exception error returned Error code 91 Invalid Response 92 COM Port Initial or Mode Error 93 COM Port Time Out Example Refer to ADAMRTU_ForceMultiCoils 5 76 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMRTU ForceMultiCoils Syntax bool ADAMHRTU ForceMultiCoils int iPort int Slave Addr int Coillndex int TotalPoint int TotalByte unsigned char szData Description OF HEX command of Modbus RTU function code Parameters Description iPort COM port number Slave Adadr Slave address Coillndex Coil address TotalPoint Quantity of coils
282. ver HTTPFTPD is a combined HTTP and FTP server that can run either as an application or as a TSH By default it processes normal HTTP requests on port port 21 80 and normal FTP requests on It also serves a proprietary session displaying the contents of text mode display memory to the RC JAR and RCCLI client applications This feature is commonly called the remote console If the HTTPFTPD server is loaded as a DOS TSR program set the HTTP DIR to the location environment variable of the INDEX HTML file for example SET HTTP_DIR CADUSOCKETS SERVER HTTPFTPD Program The syntax for FTTPD is HTTPFTPD options http port ftp port lt rc_port gt Any combination of these switches may be used They should be separated by at least one space Option Ih Ir s It u c d Ig p i lt InterruptNumber gt m lt MemorySize gt n lt MaximumConnections gt a lt ScreenX gt lt ScreenY gt v lt ScreenBufferSegmenb lt ScreenBufferOffset gt k Remarks ScreenX ScreenY Description Display help screen Run server in TSR mode Display server status Enable htaccess directory level authentication Unload if resident Close listen Do not start remote console Allow old type spawning CGI Passive mode Interrupt number for cgi API set memory size number of simultaneous connections set screen aspec set video buffer address hex Abort all active connectio
283. voz 755 701 00 2v S Removable Disk 4 4 2006 0649 7 01 00 AM Removable Disk Look in O temp C E3 2006 06 19 7 01 00 AM s ADV SRAMDRV 2006 0649 8 00 00 AM e Control Panel 2006 0649 7 01 00 AM e Shared Documents 20060649 7 01 00 AM My Documents 20060649 7 01 00 AM Local System ADAM 4500 Series 4 File name 7 object s lo byte s Files of lype Directory of D CONF DIR 06 19 2006 Ws bip WEBROOT lt DIR gt 06 19 2006 Vis Dp AUTORUN BAT 128 06 19 2006 8 08p AX8796 COM 13 312 06 19 2006 gale CFGIO EXE 35 328 06 19 2006 s bip SOCKETP EXE 48 896 06 19 2006 Pip eae 123 lt DIR gt 06 19 2006 8 28p 7 file s 97 664 bytes 754 176 bytes free start S Y ii adamasoo S ww 8 42PM 6 Restore function will start to process FIT ADAM 4500 Series Utility Ver 1 13 File Help zie x Se UNO 3072 3074 Local Disk s Removable Disk F un Removable Disk Advantech Image Worker amp dam 4500 Image Worker File Folder 2006 0649 8 02 00 AM Local System ADAM 4500 Series File Folder 20060649 7 01 00 AM File Folder 2006 0649 7 01 00 AM F lt gt ADV SRAMDRV jore 1KB MS DOSB 2006 06 19 8 00 00 AM Control Panel 13KB MS DOS A 2006 06 19 7 01 00 AM TE Hel Shared Documents HUE Hep 35KB Application 2006 069 7 01 00 AM C3 My Documents f 48KB Application 2006 06 19 7 01 00 AM Backup Image write
284. will actually get lower power The thin cable will consume the energy ADAM 4500 Series User s Manual C 9 Appendix C Grounding Reference C 2 Shielding C 2 1 Cable Shield Single Isolated Cable Use Aluminum foil to cover those wires for isolating the external noise Figure C 9 Single isolated cable e Single isolated cable The diagram shows the structure of an isolated cable You see the isolated layer which is spiraled Aluminum foil to cover the wires This spiraled structure makes a layer for shielding the cables from external noise C 10 ADAM 4500 Series User s Manual Appendix C Grounding Double Isolated Cable Second Layer First Layer Reduce wire Impedance and Use Aluminum foil ta enhance cable Intensity by cover those wires for those paralisi nude conductors Isolating the external nolse Figure C 10 Double isolated cable e Double isolated cable Figure 10 is an example of a double isolated cable The first isolating layer of spiraled aluminum foil covers the conductors The second isolation layer is several bare conductors that spiral and cross over the first shield layer This spiraled structure makes an isolated layer for reducing external noise Additionally follow these tips just for your reference e The shield of a cable cannot be used for signal ground The shield is designed for carrying noise so the environment noise will couple and interfere with your system when you use the
285. write backup ram unsigned long index unsigned char data unsigned char read backup ram unsigned long index Description write backup ram Writes a byte to battery backup memory read backup ram Reads the value in backup RAM at index address maximum 384 KB total backup RAM index 0 393214 Parameter Description index An index for data in the battery backup RAM from O to 393214 maximum 384 KB battery backup SRAM in total data A byte of data that the programmer wanis to write to battery protected SRAM Return value write backup ram None read_backup ram The single byte value in backup RAM at address index Example include 4500drv h void main unsigned long addr unsigned char data write the data 0x55 into battery backup memory index 10 data 0x55 write_backup_ram 10 data adv printf data 9exWM read backup ram 10 j Remarks None ADAM 4500 Series User s Manual 5 23 Chapter 5 Programming and Function Library Timer Init Syntax int Timer Init Description Initializes the timer built into the 80188 microprocessor The return value 0 means the initialization of the time was successful The return value 1 means the timer had already been initialized Parameter None Return value 0 Initialization was successful 1 The timer had already been initialized Remarks None Example Refer to Release All 5 24 ADAM 4500 Series User s Manual Chapter 5 Progra
286. x File Help Local System 4500DRV H Z DemoRC c DEMORC EXE E DemoRC PRJ DemoRS c E DEMORS DSK DEMORS EXE E DemoRS PRJ E DemoTC c DEMOTC EXE E DemoTC PRJ DemoTS c DEMOTS DSK PI DEMO TS EXE Ek 7 object s Resident Flash RFA Drive s D 789 C gt ECHO OFF CHON Initial Mode D gt demors init success 230 0 KB server started C Program Files Advantech 4D4M 4500 Series Utilty So Nam Size Type 12KB 1KB 23KB 5KB 1KB 3KB 41KB 5KB 3KB 48KB 5KB 2KB 3KB FIKR H Fil C Fil Appl PRJ C Fil DSK Appl PRJ C Fil App PRJ C Fil DSK amp nnL b OEM Layer CONF WEBROOT S AUTORUN BAT 4x8796 COM cFaio EXE DEMORS EXE DEMOTS EXE SOCKETP EXE 8 object s 4 46 ADAM 4500 Series User s Manual 1KB 13KB 35KB 41KB 51KB 48KB ADAM 4500 Series Bajc Ea E mja zia M1 z OoOo O Name Size Type modes File Folder File Folder MS DOS B MS DOS A Application Application Application Application 2006 07 25 6 01 00 4M 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 AM 2006 07 25 7 01 00 AM 2006 07 25 6 01 00 AM 2006 07 25 6 01 00 AM 185 9 KB 658 432 bytes free Chapter 4 Guidelines for Network Functions 3 Launch Advantech Modbus OPC Server io My Documents i lt N 7 Acc
287. y Return value None Example ADAMRTU_ModServer_Create 3 unsigned char Share Mem sizeof Share Mem adv printf server started An while 1 if predate Share Mem 0 adv_printf 40001 is X n Share Mem 0 strongly recommend use adv printf instead of printf predate Share Mem 0 j ADAM 4500 Series User s Manual 5 87 Chapter 5 Programming and Function Library Ver RTU Mod Syntax void Ver RTU Mod char vstr Description Check Modbus RTU Library version Parameter Description vstr Pointer to array of Modbus RTU version information Return value None Example char library_ver 20 void main void Ver RTU Mod library_ver Library adv_printf The version of library is s n library_ver 5 88 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library 5 3 5 MODBUS TCP Functions MBTCP LIB Ver TCP Mod Syntax void Ver TCP Mod char vstr Description Check Modbus TCP Library version Parameter Description vstr Pointer to array of Modbus TCP Library version information Return value None Example char library_ver 20 void main void Ver_TCP_Mod library_ver adv_printf The version of library is s n library_ver ADAM 4500 Series User s Manual 5 89 Chapter 5 Programming and Function Library Modbus TCP Client Functions ReturnErr code Syntax int ReturnErr code void Description When followin
288. yteCount tmpcnt adv_printf 02X HostData tmpont j adv_printf n 5 82 ADAM 4500 Series User s Manual Chapter 5 Programming and Function Library ADAMRTU ReadHoldingRegs Syntax bool ADAMRTU ReadHoldingRegs int iPort int i iAddr int iStartlndex int iTotalPoint int o iTotalByte unsigned char o szData Description 03 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave Address iStartIndex Starting Address iT otalPoint No of Points o iTotalByte Byte Count o szData Register Data Return value TRUE No error occurs FALSE Error occurs call Error Code for exact error codes Example If ADAMRTU ReadHoldingRegs COM 1 0x02 0x65 0x01 amp DataByteCount HostData adv_printf err code is d n Error_Code adv printf fail send else adv printf Status for tmpcnt 0 tmpcnt DataByteCount tmpcnt adv_printf 02X HostData tmpont j adv printf n ADAM 4500 Series User s Manual 5 83 Chapter 5 Programming and Function Library ADAMRTU ReadinputRegs Syntax bool ADAMRTU ReadlnputRegs int iPort int i iAddr int i_iStartIndex inti iTotalPoint int o iTotalByte unsigned char o szDatal Description 04 HEX command of Modbus RTU function code Parameters Description iPort COM port number i iAddr Slave Address iStartIndex Starting Address iTotalPoint No of Points o iT
289. z Se LINO 3072 3074 Local Disk 123 File Folder 2006 0649 8 02 00 AM w Removable Disk n m CERE File Folder 2005 06 19 7 01 00 AM Se Removable Disk Ai l Advantech Image Worki x File Folder 2006 06 19 7 01 00 AM S gt ADV SRAMDRV F cy ay UR Worker 1KB MS DOS B 2006 06 19 8 00 00 AM gt Control Panel HUNE NES HE 13KB MS DOS 4 2006 06 49 7 01 00 AM Shared Documents F ER cae DRE Hep 35KB Application 2006 06 19 7 01 00 AM My Documents F Backup Image 48KB Application 20060649 7 01 00 AM m Write Image Estimate time 6minutes Restore Image TI 0x 7 object s 0 byte s WARNING 95 4 KB 754 176 bytes free D m f 1 This action will restore your image SOL irectory o All the data currently on that drive will be erased CONF 1 Be sure you have at least 10KB free space on Adam 4500 WEBROOT 1 D drive and Agazz4500 is in initial mode This operation AUTORUN BAT Are you sure AX8796 COM CFGIO EXE SOCKETP EXE 125 lt DIR gt 8 28p 7 file s 97 664 bytes 754 176 bytes free d stat S y 3 i adamasoo ww 8 41PM 3 28 ADAM 4500 Series User s Manual Chapter 3 Program Download 9 Select the image file you want to reload Here we use the image file created in 3 7 Click the Open button FII ADAM 4500 Series Utility Ver 1 13 2181 x File Help Alafo z Name Size Type Modified Shov

Download Pdf Manuals

image

Related Search

Related Contents

Zebra G46382M  別紙2 チューナーの仕様等 - 総務省 地デジチューナー支援実施センター  Manual de Instruções Evolution RTK  manual del operador - DICKEY  Furuno FELCOM 500 User's Manual  Samsung YP-K3JAR User Manual    School User Manual - Schools Service Point  

Copyright © All rights reserved.
Failed to retrieve file