Home

for XPAC/WinPAC Series

image

Contents

1. PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 54 Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 2 pac GetRotarylD This function retrieves the position number of the rotary switch Syntax C int pac_GetRotarylD Parameters This function has no parameters Return Value If the function succeeds the return value is the position number of the rotary switch If the function fails the return value is invalid value To get extended error information call pac_GetLastError Examples C int RotarylD RotarylD pac_GetRotarylD CH int RotarylD RotarylD PACNET Sys GetRotarylD PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 55 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 3 pac GetSerialNumber This function retrieves the serial number of the XPAC WinPAC hardware ID Syntax C void pac _GetSerialNumber LPSTR SerialNumber Parameters SerialNumber out The serial number of the XPAC WinPAC hardware ID Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 56 Examples C char SN 32 pac_GetSerialNumber SN C string SN SN PACNET Sys GetSerialNumber Remarks If the
2. PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 439 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Misc Functions The following functions are used to retrieve or set the memory PACSDK Functions PACNET Functions Description pac_DoEvent pac_DoEvents N A Handles all events MISC GetCurrentDirectory Retrieves the current directory of the Char data type for the current pac_GetCurrentDirectory application N A Retrieves the current directory of the TCHAR data type for the current pac_GetCurrentDirectoryW application PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 440 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 1 AnsiString This function converts a unicode string to an ANSI byte array Syntax C byte AnsiString in string str Parameters Str in Points to the Unicode string to be converted Return Value Returns the ANSI byte array Examples C byte result new byte 32 IntPtr hPort PACNET UART Open COM1 115200 N 8 1 PACNET Sys ChangeSlot Convert ToByte 1 PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM result string str PACNET MISC WideString result PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 441 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks In NET if we want to convert a Uni
3. a pac _ReBoot Y Pac Getcpuverson Y o y y Pac EnabletED o Pac EnableLEos Jooo pac_BackwardCompatible J oy oY pac GetEbootverson do y y pac GetComMappins Jo o Yy a C Y Ur lt lt lt lt lt x lt lt lt lt x x lt lt lt lt lt lt pac GetPacNetVersion Y PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 49 lt Y Y Y pac_GetModuleType Y Y Y Y Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac EnableRetrigger Y pac GetBackplanelD Y pac_GetBatteryLevel pac_RegistryHotPlug Beta testing pac_UnregistryHotPlug Beta testing PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 50 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com System Information Functions The following functions are used to retrieve or set system information PACSDK Functions PACNET Functions Description C Ch ckSDKV Sys CheckSDKVersion is used to compare the version number o the currently used PACSDK dll with the specified PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 51 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac_RegistryHotPlug Beta Sys RegistryHotPlug Registers the registry after turning on the hot plug testing
4. define LENGTH 2 bool ret DWORD address O BYTE Buffer LENGTH Buffer 0 10 Buffer 1 20 ret pac_WriteMemory address Buffer LENGTH PAC_MEM_SRAM C bool ret uint address 0 byte Buffer new byte 2 10 20 ret PACNET Memory WriteMemory address Buffer 2 0 Remarks If an older program is coded to write data to the 0x2000 Ox3FFF address of the EEPROM or to the last segment of the SRAM using the SDK version 2 0 1 0 or earlier the program may fail to write the data to the EEPROM or the SRAM using the PACSDK dll or PACNET dll There are two ways to fix the problem 1 Modify the program so that the data is writhen to the OTOx1FFF address of the EEPROM or the O Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 130 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 4 pac EnableEEPROM This function sets the states of the EEPROM Syntax C void pac EnableEEPROM BOOL bEnable Parameters bEnable in Specifies the mode of the EEPROM True To turn on EEPROM False To protect EEPROM Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 131 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C define LENGTH 2 int ret
5. uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 333 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ReadModuleSafeValueDO_MF Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_value BOOL ret pac ReadModuleSafeValueDO MF hPort slot total channel amp do_value uart_Close hPort CH pac ReadModuleSafeValueDO 1f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do_ value bool ret PACNET IO pac_ReadModuleSafeValueDO hPort slot total channel ref do value PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 334 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ReadModuleSafeValueDO_MF If the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do value bool ret PACNET IO pac_ReadModuleSafeValueDO MF hPort slot total channel ref do_value PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE _10 0 255 which range is from O
6. uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int iDI_ TotalCh 8 int iDO_TotalCh 8 int iLatchTypezO DWORD IDI_Latch_ Value DWORD IDO_Latch_ Value BYTE cDI_Latch_ BitValue BYTE cDO_Latch_BitValue BOOL iRet pac_ReadDIOLatch 0 iSlot iDI TotalCh iDO_TotalCh iLatchType amp IDI Latch_ Value amp IDO_Latch_ Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 276 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iDl_ TotalCh 8 int iDO TotalCh 8 int iLatchTypezO uint IDI Latch Value uint IDO Latch Value byte cDI Latch_ BitValue byte cDO Latch BitValue bool iRet PACNET IO ReadDIOLatch hPort iSlot iDl_ TotalCh iDO_TotalCh iLatchType ref IDI Latch Value ref IDO Latch_ Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 277 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 10 pac ClearDlOLatch This function clears the latch values of DI and DO channels of the DIO module Syntax C B
7. 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue BOOL iRet pac ReadAO hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue BOOL iRet pac_ReadAO O iSlot iChannel iAO TotalCh amp fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 295 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue bool iRet PACNET IO ReadAO hPort iSlot iChannel iAO TotalCh ref fValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 296 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 15 pac ReadAI This function reads the engineering mode Al value of the Al module Syntax C BOOL pac _ReadAl
8. 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE _10 0 255 DI_ TotalCh in The total number of the DI channels of the DIO module DO_ TotalCh in The total number of the DO channels of the DIO module iLatch Type in The type of the latch value read back 1 latched high status O latched low status IDI Latch Value out The pointer to the DI latch value read back IDO Latch Value out The pointer to the DO latch value read back Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 275 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI_ TotalCh 8 int iDO TotalCh 8 int iLatchTypezO DWORD IDI_Latch_ Value DWORD IDO_Latch_ Value BYTE cDI_Latch_ BitValue BYTE cDO_Latch_BitValue BOOL iRet pac_ReadDIOLatch hPort iSlot iDl_ TotalCh iDO_TotalCh iLatchType amp IDI_Latch_Value amp IDO_Latch_ Value
9. C void pac RefreshWatchDog int wdt Parameters wdt in Specifies the Watchdog type PAC WDT HW O PAC WDT OS 1 Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 149 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_RefreshWatchDog PAC_WDT_OS CH PACNET Sys WDT RefreshWatchDog 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 150 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 4 pac _GetWatchDogState This function retrieves the watchdog state Syntax C BOOL pac _GetWatchDogState int wdt Parameters wat in Specifies the Watchdog type PAC WDT_HW O PAC WDT OS 1 Return Value If the function succeeds the watchdog is turning on the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 151 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C BOOL bState bState pac_GetWatchDogState PAC_WDT_OS C bool bState bState PACNET Sys WDT GetWatchDogState 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 152 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E m
10. Check sum is disabled The buf are five bytes ABCD 0x0 This function will send five bytes ABCD 0x0D PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 204 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 5 uart_RecvExt This function receives a string 0x0D A OxOD character is assigned to terminate the string This function is not called when the checksum is enabled by using uart_EnableCheckSum function which includes the terminate character Ox0D This function replaces uart_Recv The uart_Recv can cause the buffer overflow in some situation Syntax C BOOL uart_RecvExt HANDLE hPort LPSTR buf DWORD in_Len Parameters hPort in Handle to the open COM port buf in A pointer to a buffer that receives data out Len in A pointer to a variable that specifies the size in bytes of the buffer pointed to by the buf PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 205 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE If the function doesn t receive a character OxOD the other data still store to buf but the return value is FALSE Calling pac_GetLastError function will get an error code PAC_ERR_UART_READ TIMEOUT If this function to receive the actual data size is lar
11. DWORD address O BYTE Buffer LENGTH Buffer 0 OxAB Buffer 1 OxCD pac_EnableEEPROM true ret pac WriteMemory address Buffer LENGTH PAC MEM_EEPROM pac_EnableEEPROM false C bool ret uint address 0 byte Buffer new byte 2 OxAB OxCD PACNET Memory EnableEEPROM true ret PACNET Memory WriteMemory address Buffer uint Buffer Length 0 PACNET Memory EnableEEPROM false Remarks Before writing EEPROM need turn on the EEPROM after written EEPROM need turn off the EEPROM PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 132 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 5 pac _SDExists This function checks that the micro SD whether has been standby ready or not Syntax C bool pac SDExists Parameters This function has no parameters ReturnValue If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 133 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool bExist bExist pac_SDExists C bool bExist bExist PACNET Memory SDExists PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 134 Copyright 2013 ICP DAS Co Ltd All Rights R
12. Example 1 1f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 4 turn on the channel two bool ret PACNET IO WriteDO_MF hPort PACNET IO REMOTE_1IO 1 total channel do_value PACNET UART Close hPort Example 2 If the module is 87k local IntPtr hPort hPort PACNET UART Open int total channel 8 uintdo value 4 turn on the channel two bool ret PACNET IO WriteDO_MF hPort 1 total channel do_value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC _ REMOTE _10 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 250 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 3 pac_WriteDOBit This function writes a single bit of value to the DO module that is only the channel corresponding to the bit is changed Syntax C BOOL pac_WriteDOBit HANDLE hPort int slot int iDO_ TotalCh int iChannel int iBitValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 251 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module i
13. Examples C pac StopBuzzer CH PACNET Sys Buzzer StopBuzzer PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 92 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 23 pac _GetDIPSwitch This function retrieves the dip switch AAA RO OUP Syntax C int pac_GetDIPSwitch Parameters This function has no parameters Return Value The return value specifies the dip switch Examples C int iDipSwitch C int DipSwitch DipSwitch PACNET Backplane GetDIPSwitch PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 93 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 24 pac_GetSlotCount This function retrieves the total number of the IO slot Syntax C int pac_GetSlotCount Parameters This function has no parameters Return Value The return value is the number of the IO slot Examples C int wSlot wSlot pac_GetSlotCount C int wSlot wSlot PACNET Backplane GetSlotCount PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 94 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 25 pac_EnableRetrigger This function determines the retrigger status Syntax C void pac EnableRetrigger BYTE iValues Parameters iValues in Specifies the retri
14. bool pac_GetPWMSynChannel HANDLE port int slot short chindex short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel config out 0 Disables the PWM synchronization 1 Enables the PWM synchronization PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 402 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode BOOL iRet pac_GetPWMSynChannel hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode bool iRet PACNET PWM GetPWMSynChannel hPort iSlot iChannel ref mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 403 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 12 pac SyncPWMStart This function starts the PWM synchronization
15. unregister slot interrupt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 108 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 3 pac_EnableSlotinterrupt This function performs hardware operations necessary to enable the specified hardware interrupt Syntax C void pac EnableSlotinterrupt BYTE slot BOOL bEnable Parameters slot in Specifies the index of slot to enable interrupt or disable bEnable in Specifies the Slot interrupt turning on or not Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 109 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something pac_InterruptDone slot return true if return true SDK will do pac_InterruptDone automatically else users should do pac InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or flase needn t add pac _InterruptDone and it will work correctly void ClntrDlg OnButton1 pac_RegisterSlotinterrupt slot slot_callback proc pac_EnableSlotlnterrupt slot true enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false disable slot interrupt pac_UnregisterSlotlnterrupt slot
16. unregister slot interrupt j Remarks Default trigger type is level trigger For XP 8000 series only support level trigger type PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 110 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 4 pac SetSlotinterruptPriority This function sets the priority for a real time thread on a thread by thread basis Syntax C BOOL pac SetSlotinterruptPriority BYTE slot int nPriority Parameters slot in Specifies the index of slot to set priority nPriority in Priorities to set for the thread This value can range from 0 through 255 with 0 as the highest priority Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 111 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 5 pac_Interruptinitialize This function initializes a slot interrupt with the kernel This initialization allows the slot to register an event and enable the interrupt Syntax C BOOL pac Interruptinitialize BYTE slot Parameters slot in Specify the index of slot to initialize Return Value If the function succeeds the return value is TRUE If the functi
17. E mail service icpdas com F 8 VP 2XW1 COMO COM3 COM2 Slot 0 2 RS 232 RS 485 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 506 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com
18. Examples C pac ReBoot CH PACNET Sys Reboot PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 70 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 11 Pac_GetCPUVersion This function retrieves the version number of the CPU Syntax C void pac_GetCPUVersion LPSTR cpu_ version Parameters cpu_ version out The version number of the CPU Return Value This function does not return a value Examples C char CPU 32 pac GetCPUVersion CPU C string CPU PACNET Sys GetCPUVersion PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 71 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 12 Pac_EnableLED This function sets the state of the LED Syntax C void pac EnableLED bool bFlag Parameters bFlag Specifies the mode of the LED True Turn on the LED False Turn off the LED Return Value This function does not return a value PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Page 2 E mail service icpdas com Examples C pac_EnableLED True C PACNET Sys EnableLED True PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 73 Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 13 Pac_En
19. HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 358 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value For i 8k i 8krw 0 No action 1 by Power On Value 2 by Safe Value 3 by regular DO command For i 87k i 7k modules O others maybe poer on value or regular DO command 2 by Safe Value Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 0 int lastOutput 0 hPort uart_Open lastOutput pac_GetModuleLastOutputSource hPort iSlot uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open int lastOutput PACNET IO GetModuleLastOutputSource hPort iSlot PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 359 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which rang
20. If you delete a key which doesn t exist nothing happen If the function succeeds the function will delete the specified key including all of its subkeys and values An application cannot call RegDeleteKey for a key that an application currently has open PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 167 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 5 pac_RegDeleteValue This function removes a named value from the specified registry key Syntax C bool pac RegDeleteValue LPCTSTR KeyName Parameters KeyName in Specifics the path of registry key which you want to delete Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 168 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_RegDeleteValue TEXT HKEY_USERS myKey value C bool ret ret WinPAC RegDeleteValue TEXT HKEY_ USERS myKey value Remarks The function could be used only in leaf key And the function pac_RegDeleteKey can be used in any registry key except leaf
21. XPac WinPac Open COM4 9600 N 8 1 ret XPac WinPac BinSend hPort XPac WinPac AnsiString AB 2 ret XPac WinPac Recv hPort buf XPac Close hPort Remarks Note that this function is usually applied to communicate with the other device but not for ICPDAS DCON I 7000 8000 87K series modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 223 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 13 uart_BinSendCmd This function sends binary command and receive binary data with the fixed length This function is a combination of uart_BinSend and uart_BinRecv The operation for sending a command is the same as uart_BinSend The operation for receiving a response is the same as uart_BinRecv Syntax C bool uart_BinSendCmd HANDLE hPort LPCSTR ByteCmd DWORD in _ Len LPSTR ByteResult DWORD out Len PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 224 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in Handle to the open COM ByteCmd in A pointer to a command in_Len in The length of command string ByteResult out A pointer to a buffer that receives the data out Len in The length of result string Return Value If the function succeeds the return value is 1 If the function fails the return value is O PAC Standard API Manual v1 1 1 Last Revised Dec
22. uart_Open BYTE iSlot 1 int iChannel 2 int iDl_ TotalCh 8 DWORD ICounter_ Value BOOL iRet pac_ReadDICNT hPort iSlot iChannel iDl_ TotalCh amp lCounter_Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iDI_ TotalCh 8 DWORD ICounter Value BOOL iRet pac_ ReadDICNT O iSlot iChannel iDI TotalCh amp lCounter Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 282 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac ReadDlICNT_MF Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDI_ TotalCh 8 DWORD ICounter_ Value BOOL iRet pac_ReadDICNT hPort iSlot iChannel iDI TotalCh amp lCounter Value uart_Close hPort CH pac ReadDlICNT f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDI_ TotalCh 8 uint ICounter_ Value bool iRet PACNET IO ReadDICNT hPort iSlot iChannel iDl_ TotalCh ref ICounter Value PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 283 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ReadDICNT_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int
23. 43 System Data Hz ErcHand ling 1 ete Drawing ag Interrupt 2 reten Windows Forms ae Memory 42 System Eml Se MISC Bu 3 bin y PAC CALLEACE FUNC E 4 ob Se PAC IO W 23 Form vb Hz PAC Reg FACNET AI Se PWM tg system ke UART PACNET EFTimer w GetBFPTimerTimeTick ms w GetBFPTimerTimeTick us EillBF Timer ReferenceEquals setbPTimer ly setBP TimerlnteruptPriority O setBP Timer ut i gt TIMER i gt TIMER i gt TIMEROUT I mynno PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 45 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com The following references illustrate how to develop the programs for a variety of platforms step by step XP 8000 CE6 Refer to the chapter 4 on xp 8000 ce6 user manual for more details ftp ftp icodas com pub cd xp 8000 ce6 document user manual XP 8000 Atom CE6 Refer to the chapter 4 on xp 8000 Atom ce6 user manual for more details ftp ftp icodas com pub cd xpac atom ce6 document user manual WP 8000 Refer to the chapter 4 on wp 8000 user manual for more details ftp ftop icpdas com pub cd winpac napdos wp 8x4x ce50 document WP 5000 Refer to the chapter 4 on wp 5000 user manual for more details ftp ftp icodas com pub cd winpac napdos wp 5000 ce50 document VP 2xWx Refer to the chapter 4 on vp 2xWx user manual for more details ftp ftp icodas com pub cd winpac napdos vp 2000 ce50 document PAC Standard API Manual v1 1 1
24. Add Basic PAC_ERR_MODULE_UNEXISTS PAC_ERR_BASE 7 PAC_ERR_INVALID_SLOT_NUMBER PAC_ERR_BASE 8 Interrupt PAC_ERR_INTR_BASE 0x13000 PAC_ERR_INTR_CREATE_EVENT_FAILURE PAC_ERR_INTR_BASE 1 UART PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW PAC_ERR_UART_BASE 9 HO PAC_ERR_IO_ DO CANNOT OVERWRITE PAC_ERR_IO_BASE 10 PAC_ERR_IO_ AO CANNOT OVERWRITE PAC_ERR_IO_BASE 11 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 489 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 For XPAC series Modify The error code PAC ERR INTR CRATE EVENT FAILURE defined in XPacSDK_CE h is misspelled and it is corrected in PACSDK h as PAC_ERR_INTR_CREATE_EVENT_FAILURE nterrup Error code PAC_ERR_INTR_BASE 1 PAC_ERR_INTR_CRATE_EVENT_ FAILURE Changed to PAC_ERR_INTR_CREATE_EVENT_FAILURE Basic PAC_ERR_MODULE_UNEXISTS Original Errorcode PAC_ERR_BASE 4 Changed to PAC_ERR_BASE 7 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 490 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Add Basic PAC_ERR_INVALID_ MAC PAC ERR BASE 4 PAC_ERR_INVALID_ COMPORT_ NUMBER PAC ERR BASE 5 PAC_ERR_FUNCTION NOT SUPPORT PAC ERR BASE 6 PAC_ERR_INVALID_ SLOT NUMBER PAC ERR BASE 8 Memory Access PAC_ERR_NVRAM_INVALID_ ADDRESS PAC ERR_MEMORY_ BASE 4 PAC_ERR_EEP_WRITE_PROTECT PAC_ERR_MEMORY_BASE 5 PAC_ERR_EEP_WRIT
25. Beta testing pac_UnregistryHotPlug Sys UnregistryHotPlug Beta testing Deletes the registry key after turning off the hot plug Beta testing PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 52 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 1 pac GetModuleName This function retrieves the name of the specified 1 0 module plugged into the XPAC WinPAC series devices Syntax C int pac GetModuleName BYTE slot LPSTR strName Parameters Slot in Specifies the slot number to which 1 0 module is plugged to XPAC WinPAC series devices strName out A pointer to a buffer that receives the name of the specified 1 0 module Return Value If the 8K I O module is undefined the return value is some other value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 53 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C byte slot 1 char strName 10 pac_GetModuleName slot strName CH byte slot 1 string strName int ModuleType O ModuleType PACNET Sys GetModuleName slot ref strName because of calling by reference you should add key word ref For this API there are two overloading for NET First is above another is below whose return value is Module Name not Module type byte slot 1 string strName strName PACNET Sys GetModuleName slot
26. Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C BOOL ret HANDLE hOpen char buf Length hOpen uart_Open COM1 9600 N 8 1 ret uart_RecvExt hOpen buf Length CH bool ret IntPtr hOpen byte result new byte 64 hOpen PACNET UART Open COM1 9600 N 8 1 ret PACNET UART RecvExt hOpen result 64 Remarks A string for buf cannot include space character within the string Otherwise the string will be stoped by space character For example SO1M 02 03 of the user defined string Howerver the actual string sent out is SO1M 0xOD The terminate characters is OxOD Refer to uart_SetTerminator function to change This function will call PurgeComm to clear serial COM port output buffer This function sends data with a terminate character OxOD For example Check sum is disabled The buf are five bytes ABCD 0x0 This function will send five bytes ABCD 0x0D PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 202 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 4 uart Send This function sends data through the COM port which have been opened This function will send a string If the checksum is enabled by the uart_EnableCheckSum function this fun
27. DWORD lValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 326 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 DO_ TotalCh in The total number of DO channels of the DO modules Value in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 327 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_WriteModuleSafeValueDO Example 1 If the module is remote HANDLE hPort hPort uart Open COM2 9600 N 8 1 int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO hPort PAC REMOTE _IO 1 total channel do_ value uart_Close hPort Example 2 If the module is 87k local HANDLE hPort hPort uart_Open int total_ channel 8 D
28. Dec 2013 Page 424 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 6 pac_KillBPTimer This function destroys the specified timer event identified by type set by an earlier call to pac _SetBPTimer Syntax C void pac_KillBPTimer int type Parameters type in Specifies the timer O Timerout 1 Timer 1 1 microsecond timer 2 Timer 2 10 microsecond timer Return Value This function has does not return a value Examples C Destroy the timer 1 pac_KillBPTimer 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 425 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 10 Error Handling API The error handling functions enable you to receive and display error information for your application PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 426 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the error handling functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 5xxx VP 25Wx VP 23Wx ec Y YT OY pc YY O Yoyo pac_SetlastError pac_GetErrorMessage pac_ClearlastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 427 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Error Functions The following fun
29. E mail service icpdas com 2 5 10 pac RegGetValueBylndex This function retrieves the value of specified index of registry key Syntax C bool pac RegGetValueBylndex LPCTSTR KeyName DWORD dwlndex LPTSTR IpName Parameters KeyName in Specific the path of registry key dwlndex in Specific the index of value loName out Pointer to a buffer that receives the value s data Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret DWORD indexzO TCHAR strName 10 ret pac_RegGetValueBylndex TEXT HKEY_USERSWmyKeyW index strName C bool ret uint index 0 string strName new String 0 10 ret WinPAC RegGetValueBylndex HKEY_USERS myKey index strName PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 179 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 11 pac_RegKeyExist This function determinants the specified registry key exist or not Syntax C bool pac RegK
30. HANDLE hPort int slot int iChannel int iAl_ TotalCh float fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 297 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the Al value from the channel Al_ TotalCh in The total number of the Al channels of the Al module Value in The pointer to the Al value that is read back from the Al module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 298 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAl_ TotalCh 8 float fValue BOOL iRet pac_ReadAl hPort iSlot iChannel iAl_ TotalCh amp fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAl_ TotalCh 8 float fValue BOOL iRet pac_ReadAl 0 iSlot iChannel iAl_ Tota
31. If the function fails The return value is zero Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return O _ Interrupt done y Set timer1 with 200 microsecond interval pac_SetBPTimerOut 200 300 TIMER PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 422 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 5 pac SetBPTimerinterruptPriority This function sets the priority for a real time thread of the backplane timer Syntax C bool pac_SetBPTimerinterruptPriority int type int nPriority Parameters type in Specifies the backplane timer O Timerout 1 Timer 1 2 Timer 2 nPriority in Priority to set for the thread This value can range from O through 255 with O as the highest priority Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 423 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return 0 Interrupt done Set timer1 with 200 microsecond interval pac SetBPTimer 1 200 TIMER Set the priority of timer 1 to 100 pac SetBPTimerinterruptPriority 1 100 PAC Standard API Manual v1 1 1 Last Revised
32. PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 384 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 float fValue BOOL iRet pac_GetPWMDuty hPort iSlot iChannel amp fValue uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 float fValue bool iRet PACNET PWM GetPWMDuty hPort iSlot iChannel ref fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 385 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 3 pac SetPWMFreguency This function sets the freguency value for a specific channel Syntax C bool pac _SetPWM Frequency HANDLE port int slot short chindex unsigned long freq Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel freq in The frequency value to set to the PWM mod
33. PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel mode out O Disables the PWM continuous mode 1 Enables the PWM continuous mode If the PWM continuous mode is enabled the step value for PWM will be automatically set to 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 392 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 long mode BOOL iRet pac_GetPWMMode hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong mode bool iRet PACNET PWM GetPWMMode hPort iSlot iChannel ref mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 393 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 7 _ pac SetPWMDITriggerConfig This function sets the hardware trigger for a specific channel Syntax C bool pac SetPWMDITriggerConfig HANDLE port int slot short chindex short config Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local
34. Syntax C bool pac SyncPWMStart HANDLE port int slot short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 enStatus in O Stops the PWM synchronization 1 Starts the PWM synchronization Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 404 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 short Status 0 BOOL iRet pac_SyncPWMStart hPort iSlot Status uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 short Status 0 bool iRet PACNET PWM SyncPWMsStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 405 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 13 pac SavePWMConfig This function saves the PWM configuration Syntax C bool pac SavePWMConfig HANDLE port int slot Parameters hPort in The serial port HAN
35. XPacSDK_CE lib The CH VB net project required to refer to XPacNet dll while building and the built executable file placed in the XPAC series device must work with XPacNet dll and XPacSDK_CE dll CH VB net EE ce EU Project Refer to XPacSDK_CE dil PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 495 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com ii _ The users have used XPAC series devices and their programs is based on the old SDK XPacSDK_CE dll working with the old DCON modules and multi function DCON modules on XPAC device The new PACSDK dll provides pac_xxx_MF API functions that allow access to Multi function modules so the code must be updated in order to use the new PACSDK dll in the program Refer to How to document x6 10 How to update to PACSDK_library_from_XPacSDK_library_EN pdf for more details iii The users have never used XPAC series devices Their program will be based on the new SDK working with an old DCON module or a Multi function module Our API Manual give instructions for the PACSDK dll and the demo programs included on the shipped CD FTP are linked with the new PACSDK dll so users should refer to the demo programs and follow the API instructions when developing new programs based on the new PACSDK dll rather than those for the XPACSDK Use the new SDK as following flowchart The VC project required to link PACSDK lib while b
36. gt _ Public Shared Function pac_WriteDO hPort As IntPtr slot As Integer DO_TotalCh As Integer IDO_ Value As Ulnteger As Boolean End Function Private Sub button1_Click sender As Object e As System EventArgs Handles button1 Click pac_WriteDO CType 0 IntPtr 1 16 amp Hff End Sub PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 41 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com End Class End Namespace PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 42 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 Using PACNET dll PACNET dll is a net Compact framework SDK and PACNET dll isn t used for CH program but also used for VB net program gt _ PACNET dll the execution file should be put in the same directory of the PACNET dll The latest version of the library is located at CD root XP 8000 CE6 SDK XPacNET in the companion CD ftp ftp icodas com pub cd xp 8000 ce6 sdk xpacnet Step 1 Create a new project by using Visual Studio 2005 2008 LI File dit View Tools Test Window Help New M Project Ctl ShifteN Open PU WebSite Shift AlN Close File Ctrl Project From Existing Code save All tes Tutte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 43 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail
37. ii ne 18 1 3 Setting up the Development Environment csccscscsccscsceccccccsceccccecscsceccecs 22 1 3 1 C C MFC based on Visual Studio for XPAC series 23 1 3 2 C C MFC based on eVC for WinPAC Series 26 1 3 3 C C MFC based on Visual Studio for WinPAC Series 29 1 3 4 C for XPAC WinPAC Series 32 1 3 5 VB net for XPAC WinPAC Series 39 2 PAC APIFUDCEHODS iras 47 2 1 Syst m information AP ini 48 2 1 1 pac_GetModuleName 53 2 1 2 pac_GetRotarylD 55 2 1 3 pac GetSerialNumber 56 2 1 4 pac GetSDKVersion 58 2 1 5 pac_ChangeSlot 60 2 1 6 pac_CheckSDKVersion 62 2 1 7 pac_ModuleExists 64 2 1 8 pac_GetOSVersion 66 2 1 9 pac_GetMacAddress 68 2 1 10 pac_ReBoot 70 PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Page 3 E mail service icpdas com 2 2 ZLTE 2 1412 Zi ES 2 1 14 Zi 15 2 1 16 2 1 17 2 1 18 2 1 19 2 1 20 2 1 21 2 t22 2 123 2 1 24 2 1 25 2 1 26 2 1 27 2 1 28 2 1 29 2 2 1 2 2 2 LLO 2 2 4 2 2 2 2 6 PAR Interrupt API Pac_GetCPUVersion Pac_EnableLED Pac_EnableLEDs pac_BackwardCompatible pac_GetEbootVersion pac_GetComMapping pac_GetModuleType pac_GetPacNetVersion pac _BuzzerBeep pac_GetBuzzerFregDuty pac_SetBuzzerFregDuty pac_StopBuzzer pac_GetDIPSwitch pac_GetSlotCount pac_EnableRetrigger pac_GetBackplanelD
38. int slot short chindex short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel config in O Disables the PWM synchronization 1 Enables the PWM synchronization PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 400 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode 0 BOOL iRet pac_SetPWMSynChannel hPort iSlot iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode 0 bool iRet PACNET PWM SetPWMSynChannel hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 401 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 11 pac_GetPWMSynChannel This function reads the PWM synchronization status for a specific channel Syntax C
39. pac_BackwardCompatible C bool bBC bBC PACNET Sys BackwardCompatible PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 77 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 15 pac_GetEbootVersion This function retrieves the version number of the eboot Syntax C void pac GetEbootVersion LPSTR eboot version Parameters eboot_version out The version number of the eboot Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 78 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C char Eboot 32 pac_GetEbootVersion Eboot C string Eboot Eboot PACNET Sys GetEbootVersion PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 79 Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 16 pac GetComMapping This function retrieves the index mapping of COM port Normal mode Syntax C int pac_GetComMapping int ndx PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 80 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters ndx in Specifies which slot COM port map between backward compatible or not Return Value Return the index of COM port under the backward compatible if backwa
40. slot total channel amp do value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 344 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac_ReadModulePowerOnValueDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do value bool ret PACNET IO pac ReadModulePowerOnValueDO MF hPort slot total channel ref do_value PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 345 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 28 pac_WriteModuleSafeValueAO This function writes the AO safe value to the AO modules Syntax C BOOL pac WriteModuleSafeValueAO HANDLE hPort int slot int iChannel int iAO_ TotalCh float fValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local iSlot in The slot in which module is t
41. 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com printf The size of EEPROM is d n pac_GetMemorySize atoi argv 3 err pac_ReadMemory atoi argv 1 buffer atoi argv 2 atoi argv 3 if err FALSE pac GetErrorMessage pac GetLastError strErr printf Read EEPROM failure The error code is x n pac_GetLastError printf s strErr return O printf s n buffer y return 0 C PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 435 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com class Program static void Main string args if args Length lt 3 Console WriteLine pac_WriteDO for 8000 modules n n Console WriteLine usage pac_WriteDO Slot total channel DO s value n n else Console WriteLine where n Console WriteLine Slot n Console WriteLine number of slot for local modules n Console WriteLine total channel n Console WriteLine number of DO s channel n Console WriteLine DO s value n Console WriteLine 1 is to turn on the DO channel O is off n bool err err PACNET IO WriteDO IntPtr Zero Convert Tolnt32 args 1 Convert Tolnt32 args 2 Convert ToUInt32 args 3 if err false Cnsole WriteLine Write DO s Error PACNET ErrHandling GetErrorMessage XPac GetLastError The error code is PACNE
42. 2013 Page 225 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret HANDLE hPort char buf 2 char cmd 2 hPort uart_Open COM4 9600 N 8 1 cmd 0 0x41 cmd 1 0x42 ret uart BinSendCmd hPort cmd 2 buf 2 uart_Close hPort CH bool ret byte cmd new byte 2 IntPtr hPort byte buf new byte 2 cmd 0 0x41 cmd 1 0x42 hPort PACNET UART Open COM4 9600 N 8 1 ret PACNET UART BinSendCmd hPort cmd 2 buf 2 PACNET UART Close hPort Remarks This function will call PurgeComm to clear serial COM port output and input buffer PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 226 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 14 uart GetLineStatus This function retrieves the modem control register values Syntax C BOOL uart_ GetLineStatus HANDLE hPort int pin Parameters hPort in Handle to the open COM port pin in A variable specifies state of a pin of the COM port This parameter can be following values define CTS O define DSR 1 Hdefine R 2 Hdefine CD 3 Return Value TRUE indicates the pin s state is ON O indicates OFF PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 227 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C HANDLE h
43. 318 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannelzO DWORD ICounter_ Value BOOL iRet pac_ReadCNT hPort iSlot iChannel amp lCounter Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int Channel 0 DWORD Counter Value BOOL iRet pac_ReadCNT O iSlot iChannel amp lCounter Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 319 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannelzO uint Counter_ Value bool iRet PACNET IO ReadCNT hPort iSlot iChannel ref ICounter_Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 320 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 22 pac ClearCNT This funct
44. CE w NET Compact Framework versi n NET Compact Framework Version 3 5 bd Templates EPL a Control Empty Project Library Va Application Download additonal emulator images and smart device SDEs PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Description A project for creating a MET Compact Framework 3 5 fonns application for Windows CE Platform Page 40 E mail service icpdas com Step 3 In order to use Dilimport you should using System Runtime InteropServices and then implement the function which you want to call For example of using pac_WriteDO in NET project The function defined In PACSDK h file XPAC_API BOOL pac_WriteDO HANDLE hPort int slot int iDO_TotalCh DWORD IDO Value How to use in your NET project e Added this line in your project Imports System Runtime lnteropServices e Declare this function as following lt Dlllmport PACSDK dll EntryPoint pac WriteDO gt _ Public Shared Function pac_WriteDO hPort As IntPtr slot As Integer iDO_TotalCh As Integer IDO Value As Ulnteger As Boolean End Function e Then you can use this function pac_WriteDO in your NET project Code Snippet Imports System Windows Forms Imports System Runtime InteropServices Namespace WindowsFormsApplication2 Public Partial Class Form1 Inherits Form lt Dlllmport PACSDK dll EntryPoint pac_WriteDO
45. Cb etry for oan Step 3 Select platform PAC270 to be added to the current project HEC Smart Device Application Wizard EU a Platforms Overview Select platform SDKs to be added to the current project Platforms Application Type Installed SDKs Selected SDKs Pocket PC 2003 User Interface Features Smartphone 2003 Platform Builder Advanced Features PacSDK CE Document Template Strings Generated Classes PAC270 Instruction sets ARMA Platform Info PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 30 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 4 On the configuration toolbar select the PAC270 ARMVAl gm testidddd Microsoft e Studio File Edit View Project Build Debug Tools Test Window Help MERTER E E X Al Mu e El EL b Debug PACZ70 ARMYAD p Step 5 Include PACSDK h Hinclude PACSDK h Sinclude stdafx_h Sinclude sDKinformation h include blEInformationlle h include PACSIE H Step 6 Include PACSDK lib In the right pane choose the PACSDK lib in the Additional Dependencies item SDE Information Property Pages Confieuration Active Debug Patom Active EPacSDE CE 26 we E Common Properties Additional Dependencies PACSDE lib Configuration Properties Lenore All Default Libraries No Creneral I snecific Lib LE gnore specific Library Deployment Module Definition File CICH Add Modul
46. Dec 2013 Page 187 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 UART API Uart operations include basic management operations such as opening sending receiving and closing The following topics describe how you can operate uart programmatically using the uart functions Remarks We provide several COM port functions uart_Send uart_Recv to communicate with ICPDAS modules High profile I 87K series 811xW I 814xW series I 7000 series All the functions are based on standard COM port API functions in C CreateFile CloseHandle WriteFile ReadFile GetCommModemStatus Use these functions of this section to communicate with I 87K XPAC COM1 For I 87K module in I O slot I 87K module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 188 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com WP 8000 ViewPAC WinCE When a high profile I 87K is plugged in slot please call the function pac_ChangeSlot to change to the specific slot before doing other operations Please refer to demo 87k_ Basic About I 87K commands DCON protocol please refer http ftp icpdas com pub cd 8000cd napdos dcon io module 87k high profile modules h tm PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 189 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Although user can use
47. ICP DAS product you can contact ICP DAS Customer Support in one of the following ways Visit the ICP DAS Storage Manager technical support Web site at http www icpdas com fag faq htm gt Submit a problem management record PMR electronically from our Web site at http www icpdas com sevices contact customerservice htm gt Send e mail to service icpdas com PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 14 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Revision History The table below shows the revision history Revision Date Description 1 1 0 January Added the information about the defined slots and COM ports 2013 in appendix F December Modified Backplane timer API function supports 2013 Modified Error handling API function supports Add usage remarks for pac_GetModuleLastOutputSource pac_GetModuleWDTStatus functions and etcs PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 15 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 Getting Started This chapter provides a guided tour that describes the steps needed to know download install and configure of the basic procedures for user working with the PACSDK for the first time 1 1 Introducing the PACSDK PACSDK are software development kits that contain header files libraries documentation and tools required to develop applications for
48. Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Beta testing Beta testing PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 458 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Interrupt Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac Registeriotinterrup pac unregsteiolmert Y Y YF YT oro o pac_EnableSlotinterrupt pac_SetSlotlnterruptPriority Y Y pac_Interruptinitialize lt i t l i t i t lt pac Getslotinterruptevent Y O Yo Jo oy oro o pac_SetSlotlnterruptEvent pac SetTriggerType ro poro pr oro UN pac_GetSlotinterruptiD pac_InterruptDone lt lt AM lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 459 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Memory Access Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx fpacreadmemoy Y 3 a ca pac WriteMemoy Y Y O lc o Y va po pac EnableEgPROM Y YO 3 I jeac soests MCE jpacsomount pac SDOnside UCH jpac soun
49. Open byte slot 1 int total channel 8 uint do value bool ret PACNET IO ReadDO MF hPort slot total_ channel ref do value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 258 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 5 pac ReadDI pac ReadDI MF This function reads the DI value of the DI module Syntax C for pac_ReadDI BOOL pac _ReadDI HANDLE hPort int slot int iDI TotalCh DWORD IDI Value C for pac_ReadDI_ MF BOOL pac ReadDl_ MF HANDLE hPort int slot int iDI TotalCh DWORD IDI Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 259 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 DI_ TotalCh in The total channels of the DI module IDI_ Value out The pointer to DI value to read back Re
50. PACNET UART Open byte iSlot 1 int iValue 8 bool iRet PACNET IO ReadAIAllHex hPort iSlot iValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 316 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC _REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 317 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 21 pac ReadCNT This function reads the counter values of the counter freguency modules Syntax C BOOL pac ReadCNT HANDLE hPort int slot int iChannel DWORD lCounter_ Value Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iChannel in The channel that reads the counter value back from the counter freguency module ICounter Value out The pointer to the counter value that reads back from the counter frequency module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page
51. Project types Templates E Visual Cf n Windows Web me smart Device Project i omar Device Office My Templates Database Reporting jeeerch Online Templates oo Bele peripitomponent ele _ecriptTask i Test WCF ee Workflow H Other Languages H Other Project Types H Test Projects EE Visual Studio installed templates project for Smart Device applications Choose target platfonn Framework version and template in the next dialog box Name smeatDeviceProjectl Pm martDeviceProjectl Create directory for solution E Coma solution Mame Add New Smart Device Project SmartDeviceProgectl Target platform NET Compact Framework version WET Compact Framework Version 2 5 e Templates Empty Project Class Library Console Control Application Library Download additonal emulator images and smart device STE PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved me Description 4 project for creating a NET Compact Framework 3 5 forme application for Windows CE Platform Last Revised Dec 2013 Page 33 E mail service icpdas com Step 3 In order to use Dilimport you should using System Runtime InteropServices and then implement the function which you want to call For example of using pac_WriteDO in NET project The function defined In PACSDK h file XPAC_API BOOL pac_WriteDO HANDLE hPort int s
52. Revised Dec 2013 Page 88 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int fq 0 int du 0 pac GetBuzzerFregDuty amp fg amp du C int fq 0 int du 0 PACNET Sys Buzzer GetBuzzerFreqDuty ref fq ref du PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 89 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 21 pac_SetBuzzerFreqDuty This function sets the frequency value and duty cycle value of the buzzer Syntax C void pac SetBuzzerFreqDuty int freq int duty Parameters freq out The frequency of the sound duty out The duration of the sound Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 90 Examples C int fq 500 int du 20 pac GetBuzzerFreqDuty fa du C int fq 500 int du 20 PACNET Sys Buzz GetBuzzerFregDuty fg du PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 91 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 22 pac_StopBuzzer This function stops the buzzer Syntax C void pac StopBuzzer Parameters This function has no parameters Return Value This function does not return a value
53. Rights Reserved Elle Description project for creating a NET Compact Framework 3 5 forme application for Windows CE Platform Empty Project Last Revised Dec 2013 Page 37 E mail service icpdas com Step 3 Add the PACNET dll into the references of the project and using PACNET a 88 EE on HSE Exemple 1 H Fusing System S E 42 Example using System Collections Generic Sal Properties using System Componenthodel b Eg oe using mwetem llata GB mscorlib using System Drawing using Swstem Text 423 PACNET using wetem Windows Forms 42 System 4 System Data g namespace Example 28 System Drawing a public partial class Forml Form 4 System Windows Forms T 43 System Anl public Formli 3 E me LE Form cs r gt InitializeComponentt 3 Program cs I 1 zP EntCode 3 ErrHand ling 3 Intermpt 3 Mer ces 3 rico Ll 3 MIRC y PAC CALLBACE FUNC 3 PAC IO 4 PAC Reg T nx 3 PWM ig System 7 e UART Ds 4 E A ag Watchdog oe PACHET bP Timer Ag GetBP Timer Time Tick_me ig GetBP TimerTime Tick us ig EillBF Timer PeferenceEquals ig SetBF Timer O gt etBP TimerInterruptEriority O SetBPTimer nt i TIMER1 TIMER a TIMEROUT PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 38 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 5 VB net for XPAC WinPAC Series Required library files The following DLL
54. This channel number is only valid if the return value is TRUE Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 312 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iValue 8 int ichannelnumber 0 BOOL iRet pac_ReadAlAllHexExt hPort iSlot iValue 8 amp ichannelnumber uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int ichannelnumberzO int iValue 8 BOOL iRet pac_ReadAlAllHexExt 0 iSlot iValue 8 amp ichannelnumber CH If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int ichannelnumberzO int iValue 8 bool iRet PACNET IO ReadAlAllHex hPort iSlot iValue 8 ref ichannelnumber PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 313 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revis
55. UART API to set and read values for high profile I 87K series modules we provide a more convenient API to do it Please refer to Section 7 PAC_IO API Use these functions of this section to communicate with external devices by l S11xW 1I 814xW serises modules XPAC Any serial devices connected with COM port I 7000 or I 87K4 5 8 9 Any serial devices connected with COM port E fl E 1700007 __1 87K4 5 8 9 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 190 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com WP 5000 The WP 5000 series has no slots for plugging the high profile I 8K and I 87K series but the UART API on this section can also be used for COM1 COM2 COM3 of WP 5000 series In addition of COM1 COM2 COM3 all of the functions can be used to communicate with external device by XW5xxx expansion board To see more information please reference user manual Chapter 5 API and Demo Reference PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 191 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the UART functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx R SE c p jvartsenget _ Y 3 c YO 03 oro oro lt lt lt lt lt lt lt lt lt lt
56. Value Interrupt status PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 375 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 int iSlot 0 short sStatus O sStatus pac_GetModuleWDTInterruptStatus iSlot C int iSlot 0 short sStatus O sStatus PACNET IO GetModuleWDTInterruptStatus iSlot Remarks I 8K series modules provided with Power ON or Safe Value function can support this API function At present only I 8041RW has this feature in all I 8K modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 376 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 40 pac SetModuleWDTinterruptStatus This function enables disables interrupt of a module watchdog Syntax C bool pac_SetModuleWDTInterruptStatus int slot short enStatus Parameters slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 enStatus in Interrupt status Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 377 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 int iSlot 0 short sStat
57. Watchdog type PAC_WDT_HW PAC_WDT_OS value in Specifies the watchdog time Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 155 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C DWORD dwTime 1000 pac SetWatchDogTime WINpac_WDT_OS dwTime C uint uTime 1000 PACNET Sys WDT SetWatchDogTime 1 uTime Remarks The same as the pac_EnableWatchDog function The unit of the second paremeter of the OS watchdog is second In addition the unit can not be zero for XPAC series only The hardware watchdog second Parameter is a value which is between 0 63 unit A unit is about 0 5 seconds O means the shortest timeout otherwise 63 is longest which is about 30 seconds for WinPAC series only The same as the pac_EnableWatchDog function The hardware watchdog second Parameters is a value which is between 0 31 unit A unit is about 200 milliseconds O means the shortest timeout otherwise 31 is longest PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 156 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 Registry API Registry operations include basic management operations such as reading from and writing to the registry The following topics describe how you can create delete or modify registry keys programmatically us
58. WinPacNet dll PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 492 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com ii The users have used WinPAC series devices and their programs is based on the old SDK WinPacSDK dll working with the old DCON modules and multi function DCON modules on WinPAC device The new PACSDK dll provides pac_xxx_MF API functions that allow access to Multi function modules so the code must be updated in order to use the new PACSDK dll in the program Refer to How to document w6 10_How_to_update_to_PACSDK_library_from_WinPacSDK_library_EN pdf for more details iii The users have never used WinPAC series devices Their program will be based on the new SDK working with an old DCON module or a Multi function module Our API Manual give instructions for the PACSDK dll and the demo programs included on the shipped CD FTP are linked with the new PACSDK dll so users should refer to the demo programs and follow the API instructions when developing new programs based on the new PACSDK dll rather than those for the WinPACSDK Use the new SDK as following flowchart The VC project required to link PACSDK lib while building and the built executable file placed in the WinPAC series device must work with PACSDK dll VC Project Link gt C EXE ARM PACSDK lib PC WinPAC The CH VB net project required to refer to PACNET dll while building and the built exec
59. You also need to know the expansion capacities in order to choose the best expansion module for achieving maximal efficiency For more information about expansion modules that are compatible with the XPAC WinPAC series please refer to I 8K I 87K series http www icpdas com products PAC i 8000 8000 IO modules htm I 7K series http www icpdas com tw product solutions remote io rs 485 i 7000 amp m 7000 i 7000 i ntroduction html I 8K units http www icodas com tw product solutions pac ipac ipac introduction html tM series http www icpdas com products Remote lO tm series introduction htm PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 234 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com API functions for the Multi function DCON modules PAC_IO API has provided 2 types functions One type which includes pac_WriteDO pac_ReadDIO pac_ReadDl pac_ReadDO pac_ReadDIO_DIBit pac ReadDIO DOBit pac_ReadDIBit pac ReadDOBit pac_ReadDICNT and pac_ClearDICNT functions is used to access the pure DIO DCON modules which are defeind as modules that only has DI DO or DIO channels The other type which includes pac_WriteDO_MF pac_ReadDIO_MF and pac_ReadDI_ MF etc functions is used to access the Multi function DCON modules which are defined as modules that mainly act as AlO or Counters but are equipped with DIO channels Such as the I 87005W I 87016W I 87082W I 7016 I 7088 etc Th
60. bFlag is been reserved and a new API function has been added pac_EnableLEDs int pin bool bFlag PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 471 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 Add Registry API for XPAC series The suite of the API functions listed below doesn t been provided in the previous SDK XPACSDK_CE dl and supported in the new PACSDK dll for the XPAC series The previous SDK WinPACSDK dll for the WinPAC series and the new SDK PACSDK dll for the WinPAC series have provided the support of all the functions below pac_RegCountKey pac_RegCountValue pac_RegCreateKey pac_RegDeleteKey pac_RegDeleteValue pac RegsGetDWORD pac_RegGetKeyBylndex pac_RegGetKeylnfo pac_RegGetString pac_RegGetValueBylndex pac_RegKeyExist pac_RegSave pac_RegSetString pac_RegSetDWORD PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 472 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 3 Add I O WDT PowerOn Safe Value API for pure DIO modules The new PACSDK dll provides the support of 1 0 WDT Power On and Safe value functions for pure DIO DCON modules Refer to Note 1 These functions aren t supported for the previous SDK WinPacSDK dll and XPacSDK_CE dll pac_GetModuleLastOutputSource pac _GetModuleWDTStatus pac _GetModuleWDTConfig pac_SetModuleWDTConfig pac_ResetModuleWDT pac_RefreshModuleWDT pac_InitM
61. bool ret ret pac_SDOnside C bool ret ret PACNET Memory SDOnside PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 138 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 8 pac SDUnmount This function dismounts Micro SD if the Micro SD has been mounted Syntax C bool pac SDUnmount Parameters This function has no parameters ReturnValue If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 139 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_SDUnmount C bool ret ret PACNET Memory SDUnmount PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 140 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 Watchdog API A watchdog timer is an electronic timer that is used to detect and recover from PAC malfunctions During normal operation the computer PAC restarts the watchdog timer to prevent it from elapsing or timing out If due to a hardware fault or program error the PAC fails to restart the watchdog the timer will elapse and generate a timeout signal The timeout signal is used to initiate corrective a
62. by uart_Open if the module is 87k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 iChannel in The channel that is written thee AO value to iAO_ TotalCh in The total number of the AO channels of the AO module float fValue in The AO value to write to the AO module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 352 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue 5 BOOL iRet pac_WriteModulePowerOnValueAO hPort iSlot Channel AO_TotalCh fValue uart_Close hPort C If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int Channel 2 int iAO_TotalCh 8 float fValue 5 bool iRet PACNET IO WriteModulePowerOnValueAO hPort iSlot iChannel iAO_TotalCh fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 353 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks 1 The function can support for Local
63. channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 337 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_WriteModulePowerOnValueDO Example 1 If the module is remote HANDLE hPort hPort uart Open COM1 9600 N 8 1 int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO hPort PAC REMOTE IO 1 total channel do_value uart_Close hPort Example 2 If the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO hPort 1 total channel do value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 338 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_WriteModulePowerOnValueDO_MF Example 1 1f the module is remote HANDLE hPort hPort uart Open COM1 9600 N 8 1 int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO MF hPort PAC REMOTE IO 1 total channel do_value uart_Close hPort Example 2 If the module is 87k local HANDLE hPort hPort uart_Open i
64. files is needed to include to develope a XPAC WinPAC application or plug in gt PACSDXK dII gt _ PACSDK_PWM dll If 1 7K 1 87K PWM modules is used on the device How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 1 Using DII Import Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Toole Test Window Help N Pi Broject Cult shift Open b BO WebSite Shift Alt M File t Project From Existing Code save All Ctltshaittte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 39 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select Smart Device Hew Project Project types E Visual Basic is Windows Web je mart Device Project mad Device i Office Database Reporting z Test o WCF 2 Workflow i Visual CH tl Visual C Other Project Types H Test Projecte Templates Visual Studio installed templates My Templates search Online Templates CE project for Smart Device applications Choos target platfonn Framework version and template in the next dialog box SDE Taformation CADocuments and pettiness Windows My Document WM Windowsd My Documents we SDE Intormation Create directory for solution Name Location solution Name Add New Smart Device Project SDKlnformation Target platform Windows
65. giving not only the parameters and variables of methods but also some descriptions for these methods classes and namespaces Those description of tooltips are same on the PAC API manual Refer to the following figure Wold testi i class PACNET BP Time Backplane timer PT y PAC CALLBACK FUNC e PAC IO z PAC Reg void testi i FACNET Svs Changes lot E ave Change lot byte slotNo p slotNo im J pecifies the slot number Note The PACNET dll referred to the project and PACNET xml must be placed at the same folder and the tooltip will show in the Visual studio IDE well PACNET dll PACNET AML PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 487 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C 3 Error code modifications and updates 1 For WinPAC series Modify The error code PAC ERR_EEP_ACCESS RESTRICTION and PAC ERR_SRAM_INVALID_ TYPE defined in WinPacSDK h are modified as PAC_ERR_EEP_INVALID_ ADDRESS and PAC_ERR_MEMORY_INVALID_ TYPE defined in PACSDK h Error code PAC_ERR_MEMORY_ BASE 1 PAC_ERR_EEP_ACCESS_RESTRICTION Changed to PAC_ERR_EEP_INVALID_ ADDRESS Error code PAC_ERR_MEMORY_ BASE 3 PAC_ERR_SRAM_INVALID_ TYPE Changed to PAC_ERR_MEMORY_INVALID_ TYPE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 488 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com
66. iDI TotalCh int iLatchType DWORD IDI Latch_ Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 268 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_lO 0 255 DI_ TotalCh in The total number of the DI channels of the DI module iLatch Type in The latch type specified to read latch value back 1 latched high status O latched low status IDI Latch Value out The pointer to the latch value read back from the DI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 269 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDl_ TotalCh 8 int iLatchType 0 DWORD IDI Latch Value BOOL iRet pac_ReadDILatch hPort iSlot iDl_ TotalCh iLatchType amp IDI_Latch_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iDl_ TotalCh 8 int iLa
67. iDl_ TotalCh 8 uint ICounter_ Value bool iRet PACNET IO ReadDICNT hPort iSlot iChannel iDI TotalCh ref ICounter Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 284 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 12 pac _ClearDICNT pac_ClearDICNT_MF This function clears the counter value of the DI channel of the DI module Syntax C for pac_ClearDlCNT BOOL pac_ClearDICNT HANDLE hPort int slot int iChannel int DI TotalCh C for pac_ClearDICNT MF BOOL pac_ClearDlCNT_MF HANDLE hPort int slot int iChannel int iDl_ TotalCh PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 285 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Channel in The channel that the counter value belongs DI_ TotalCh in Total number of t
68. key If you would delete a leaf key you should call pac_RegDeleteValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 169 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 6 pac_RegGetDWORD This function retrieves value of the specified registry key Syntax C DWORD pac_RegGetDWORD LPCTSTR KeyName Parameters KeyName in Specific the path of registry key Return Value Return the value of the specific key PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 170 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C DWORD dwValue dwValue pac_RegGetDWORD TEXT HKEY_USERS myKey value C uint uValue uValue WinPAC RegGetDWORD HKEY_USERS myKey value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 171 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 7 pac_RegGetKeyBylndex This function retrieves the name of specified index of registry key Syntax C bool pac RegGetKeyBylndex LPCTSTR KeyName DWORD dwlndex LPTSTR IpName Parameters KeyName in Specific the path of registry key dwlndex in Specific the index of registry key loName out Assign a buffer to retrieves the specific the key name Return Value Return true if success otherwise false To get an error code c
69. lt lt lt 4 4 i 4 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 192 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com UART Functions The following functions are used to retrieve or set the UART PACSDK Functions PACNET Functions Description UART BinSend Sends out command string with or without null character under the consideration of the command uart_BinSend length UART BinRecv Receives the response string data with or without null character under the consideration of receiving uart_BinRecv length uart_BinSendCmd UART BinSendCmd Sends binary command and receive binary data with the fixed length uart_GetLineStatus UART GetLineStatus Retrieves the modem control register values PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 193 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com UART GetDataSize Retrieves the number of bytes received by the serial provider but not yet read by a uart_Recv uart_GetDataSize aa operation or of user data remaining to transmitted for write operations uart_SetLineStatus UART SetLineStatus Sets the status of modem line PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 194 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 1 uart Open This function opens the COM port and specifies the bau
70. pac_GetBatteryLevel pac RegistryHotPlug Beta testing pac UnregistryHotPlug Beta testing pac_RegisterSlotlnterrupt pac_UnregisterSlotlnterrupt pac_EnableSlotinterrupt pac_SetSlotlnterruptPriority pac_Interruptinitialize pac_GetSlotlnterruptEvent pac_SetSlotlnterruptEvent PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Page 4 E mail service icpdas com 71 72 74 76 78 80 82 85 86 88 90 92 93 94 95 96 107 109 111 112 114 115 2 2 8 2 29 pac_SetTriggerType pac_GetSlotlnterruptlD 2 2 10 pac_InterruptDone 2 3 2 31 2 3 2 2 3 3 2 3 4 273 5 2 3 6 pie 2 3 8 2 4 2 4 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 5 2 5 1 2 59 2 25 3 2 5 4 2 2 5 0 2 5 7 Memory Access API Watchdog API Registry API pac_GetMemorySize pac_ReadMemory pac_WriteMemory pac_EnableEEPROM pac_SDExists pac_SDMount pac_SDOnside pac SDUnmount pac_EnableWatchDog pac_DisableWatchDog pac_RefreshWatchDog pac_GetWatchDogState pac_GetWatchDogTime pac_SetWatchDogTime pac_RegCountKey pac_RegCountValue pac_RegCreateKey pac _RegDeleteKey pac_RegDeleteValue pac _RegGetDWORD pac_RegGetKeyBylndex PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Pa
71. service icpdas com Step 2 Select Smart Device Hew Project ele nant NET Framework 3 5 VHE E Visual Basic Visual Studio installed templates o Windows 5 Web El ment Device Project smart Device Office My Templates Jeearch Online Templates El Other Project Types H Test Projects A project for met Device applications Choos target platform Framework version and template in the next dialog box Name SUE Information Location C Documents and pettiness Windows by Documenta WM Windowsd My Document solution Name SDE Information Create directory for solution Add New Smart Device Project 5DETnformaHon Target platform Windows CE k NET Compact Framework verson WET Compact Framework Version 3 5 hy Templates ae _ Device Empty Project A project for creating a NET Applicaton Compact Framework 2 5 forms application for Windows CE Platform Download additonal emulator images and smart device ADEs PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 44 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 3 Add the PACNET dll into the references of the project and using PACNET ala maa Fm A Wifi ae solution Example il project a Public Class Forml E el Example H a My Project Private Sub Formi Load ByVal sender As System Object ByVal e El oy References I 3 FACNET End amp ub T System End Cla s
72. slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel config in O Disables the hardware trigger 1 Enables the trigger start 2 Enables the trigger stop PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 394 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode 0 BOOL iRet pac SetPWMDITriggerConfig hPort iSlot iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode O bool iRet PACNET PWM SetPWMDITriggerConfig hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 395 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 8 pac GetPWMDDITriggerConfig This function reads the hardware trigger for a specific channel Syntax C bool pac GetPWMDITriggerConfig HANDLE port int slot short chlndex short config Parameters hPort in The serial p
73. to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 335 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 26 pac _WriteModulePowerOnValueDO pac_Wri teModulePowerOnValueDO_MF This function writes the DO power on values to DO modules Syntax C for pac WriteModulePowerOnValueDO BOOL pac_WriteModulePowerOnValueDO HANDLE hPort int slot int iDO TotalCh DWORD IValue C for pac_WriteModulePowerOnValueDO_ MF BOOL pac_WriteModulePowerOnValueDO MF HANDLE hPort int slot int iDO_TotalCh DWORD Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 336 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 DO_ TotalCh in The total number of DO channels of the DO modules Value in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output
74. to the string This function will provides a string without the last byte OxOD Syntax C BOOL uart_RecvExt HANDLE hPort LPSTR buf Parameters hPort in Handle to the open COM port buf in A pointer to a buffer that receives data Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE If this function doesn t receive a characterOxOD the other data still store to buf but the return value is O Calling pac_GetLastError function will get an error code pac_ERR_uart_READ TIMEOUT PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 208 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C BOOL ret HANDLE hPort char buf 10 hPort uart_ Open COM2 9600 N 8 1 ret uart_Recv hPort buf uart_Close hPort C bool ret IntPtr hPort string buf hPort PACNET UART Open COM2 9600 N 8 1 ret PACNET UART Recv hPort WinPAC AnsiString buf PACNET UART Close hPort Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change For example a Check sum is disabled This function receives five bytes ABCD 0x0D The buf will be five bytes ABCD 0x0 b Check sum is disabled This function receives four bytes ABCD The buf will be four bytes ABCD But the reurn value is 0 PAC Standard API Manual v1 1
75. uType WinPAC RegGetKeyinfo HKEY _USERS myKey value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 175 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 9 pac RegGetString This function retrieves value of the specified registry key Syntax C bool pac RegGetString LPCTSTR KeyName LPTSTR IpData DWORD dwLength Parameters KeyName in Specific the path of registry key loData out Pointer to a buffer that receives the value s data dwLength in Specific the size of data Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 176 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret TCHAR strName 10 ret pac_RegGetString TEXT HKEY_USERS myKey value strName sizeof strName C bool ret string strName new String 0 10 ret WinPAC RegGetString HKEY_USERS myKey value strName uint strName Length PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 177 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
76. 1 Create a new project by using eVC File Edit View Insert Project Build Tools Window Help D REA CtrlrN a Open Ma Files Projects Workspaces El WCE Application Project name SI WCE ATL COM AppWizard OO 1 WCE Dynamic Link Library fe VCE MFC ActiveX ControlWizard s i Location sA WCE MFC AppWizard dll cto BA WCE MFC AppWizard exe CAWINDOWS CE TOOLS CH bed Savi 5 WCE Static Library Open Worksr Create new workspace Add to current workspace E Depend ncy Of VWin32 WCE ARMV4 Win32 WCE ARMVAI Recent Files Win32 WCE ARMVAT Win32 WCE MIPS16 Recent Wor Win32 WCE MIPSII WWin32 WCE MIPSII_FP Exit OK PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 26 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select WCE MFC AppWizard exe Mew Files Projects Workspaces a WCE Application Project name AWCE ATL COM AppWizard lsysteminfo WCE Dynamic Link Library VCE MFC Activex Control izard Location JS WCE MFC AppWizard dll see WCE MFC AppWizard exe CAWINDOWS CE TOOLS Ctt sy E S wWCE Static Library w Create new workspace C Add to current workspace Dependency of Hello a CPUs WWin32 WCE ARMV4 MWin32 WCE ARMYAI LlWin32 WCE ARMV4T LlWin32 WCE MIPS16 WWin32 WCE MIPSII WWin32 WCE MIPSIL FP TH 4 cnet Step 3 Select platform Win32 WCE ARMVA4
77. 1 1 Last Revised Dec 2013 Page 231 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 PAC_IO API PAC_IO API supports to operate IO modules which can be divided into the following parts Local IO in slot In the local mode the slot range is from O to 7 the same the iSlot as follow hPort uart_0pen Clear DO pac_WriteDO hPort istot iDo_TotalCh 6 Local I O Functions li il lj 7 i in Local lO Function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 232 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remote If remote mode the address need call a macro PAC_REMOTE_IO And its range is from O to 255 For example as follow Write DO value to remote module HANDLE hPort uart_Open ConnectionString if thPort AfxMessageBox T Open Com Error pac_WriteDO hPort PAC REMOTE IO i ddr m_iDOCHs 1D0_ Value CGOM3 Remote o Function Fi E 7 i i r Vi ir L ay Pr n PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 233 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com In PACSDK dll modify the processing to send the DCON commands without determining the module name the new PAC_IO API functions can support to access the I 87K I 8K High profile and Low profile I 7K 1 8000 units tM series and etc DCON modules
78. 1 Last Revised Dec 2013 Page 209 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 7 uart_SendCmdExt This function sends commands through the COM port which has been opened This function is a combination of uart_SendExt and uart_RecvExt The operation for sending a command is the same as uart_SendExt The operation for receiving a response is the same as uart_RecvExt This function replaces uart_SendCmd The uart_SendCmd can cause the buffer overflow in some situation Syntax C BOOL uart_SendCmdeExt HANDLE hPort LPCSTR cmd DWORD out Len LPSTR szResult DWORD in_Len PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 210 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in Handle to the open COM cmd in A pointer to a command out Len in A pointer to a variable that specifies the size in bytes of the buffer pointed to by the buf szResult out A pointer to a buffer that receives data in_Len in A pointer to a variable that specifies the size in bytes of the buffer pointed to by the szResult Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 211 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C
79. 1 Last Revised Dec 2013 Page 369 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int iSlot 0 hPort uart_Open pac _ResetModuleWDT hPort iSlot uart_Close hPort CH If the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open PACNET IO ResetModuleWDT hPort iSlot PACNET UART Close hPort Remarks 3 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE _IO 0 255 which range is from O to 255 4 7K I 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 370 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 37 pac_RefreshModuleWDT This function refresh the host watchdog of a module Syntax C bool pac_RefreshModuleWDT HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0
80. 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 371 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int iSlot O hPort uart_Open pac_RefreshModuleWDT hPort iSlot uart_Close hPort CH If the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open PACNET IO RefreshModuleWDT hPort iSlot PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE _IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 372 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 38 pac_InitModuleWDTInterrupt This function initializes and enables interrupt of a module watchdog Syntax C bool pac_RefreshModuleWDT int slot PAC CALLBACK FUNC f Parameters slot in The slot in which module is to receive the comma
81. 3 Page 331 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 25 pac ReadModuleSafeValueDO pac_ReadMod uleSafeValueDO MF This function reads the safe value of the DO modules Syntax C for pac ReadModuleSafeValueDO BOOL pac ReadModuleSafeValueDO HANDLE hPort int slot int iDO TotalCh unsigned long lValue C for pac_ReadModuleSafeValueDO_ MF BOOL pac_ReadModuleSafeValueDO MF HANDLE hPort int slot intiDO_TotalCh unsigned long IValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 332 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iChannel in The total number of DO channels of the DO modules Value in The pointer of the DO safe value to read from the DO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C pac_ReadModuleSafeValueDO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do value BOOL ret pac_ReadModuleSafeValueDO hPort slot total channel amp do_ value
82. 7088W module I 7K series http www icpdas com tw product solutions remote io rs 485 i 7000 amp m 7000 i 7000 m 7 000 selection html such as l 7088 The suit of the PWM API functions isn t applied to the I 8K PWM module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 379 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PWM functions Functions Models XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx XP 8000 CE6 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 380 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com PWM Functions The following functions are used to retrieve or set the PWM PACSDK Functions PACNET Functions Description 2 8 1 pac SetPWMDuty This function sets the duty cycle value for a specified channel Syntax C bool pac SetPWMDuty HANDLE port int slot short chindex float duty Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel duty in The duty cycle value to write to the PWM modu
83. 8 int iBitValue 1 bool ret PACNET IO WriteDOBit hPort iSlot iChannel miDO_TotalCh iBitValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 254 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 4 pac ReadDO pac ReadDO MF This function reads the DO value of the DO module Syntax C for pac ReadDO BOOL pac ReadDO HANDLE hPort int slot int iDO_TotalCh DWORD IDO Value C for pac_ReadDO_MF BOOL pac_ReadDO_ MF HANDLE hPort int slot int iDO TotalCh DWORD IDO Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 255 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 DO_ TotalCh in The total number of DO channels of the DO modules IDO_Value in The pointer of the DO value to read from the DO module Return Val
84. 92 2 On XPAC devices 495 Appendix E How to upgrade the WinPACSDK dll XPACSDK dll 497 Appendix F Comparison of Defined Slots and COM Ports 498 E1 XP 8041 CE6 ce y D ne 499 F 2 XP 8341 CE6 XP 8741 CE6 scsccocsesccccnssccccnssccccnsscccssscccssssccessseccnsssescnasseseness 500 F3 NS EA 1 Atom CEG iaa 501 F 4 XP 8341 Atom CE6 XP 8741 Atom CE6 ssecccsssecccsssscccessscccessscccesssescesseeeseens 502 ESSWP IL iaa ind 503 FO WP 84X WIP LAA A 504 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 10 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com EJ WP 5141 WP 5141 OD irc iaa acia F 8 VP 2xW1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 11 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com About this Guide This manual is intended for software developers who want to integrate XPAC WinPAC functionality into their applications What Models are covered in this Manual The following PAC models are covered in this manual XPAC family for x86 platform series XP 8000 CE series XP 8041 CE6 WinCE 6 0 Based Standard XPAC with 0 1 0 slot XP 8341 CE6 WinCE 6 0 Based Standard XPAC with 3 1 0 slots XP 8741 CE6 WinCE 6 0 Based Standard XPAC with 7 1 0 slots XP 8000 Atom CE6 series XP 8141 Atom CE6 WinCE 6 0 Based Standard XPAC with 1 1 0 slot XP 8341 Atom CE6 W
85. ACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 310 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 19 pac ReadAlAllHexExt This function reads all the AI values of all channels in 2 s complement mode of the Al module This function replaces pac_ReadAlAllHex Syntax C BOOL pac _ReadAIAllHex HANDLE hPort int slot int iValue DWORD Buff Len DWORD Channel PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 311 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iValue out The array contains the Al values that read back from the AI module Buff_Len in A pointer to a variable that specifies the size of the buffer pointed to by the iValue Channel out The pointer to a variable that specifies the total available channel numberer of Al module
86. ACSDK lib In the right pane choose the PACSDK lib in the Additional Dependencies item SDE Information Property Pages E Common Properties Additional Dependencies PACSDE Hb Configuration Properties Ignore All Default Libraries No General I snecific Lib a Derosa gnore Specific Library Deployment Module Definition File C Add Module to Assembly Linker General Embed Managed Resource File Input Force Symbol References Manifest File Delay Loaded DLLs Debugging Assembly Link Resource System Optimization Embedded IDL Advanced Command Line Resources XML Document Generator Browse Information Build Event Custom Build Step A uthentieode Sening Additional Dependencies Specifies additional items to add to the link line ex Eemnel 22 lib configuration specific PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 25 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 2 C C MFC based on eVC for WinPAC Series Required header and library files The following list lists the libraries header files or DLL files you will need to include developing a WinPAC application or plug in gt PACSDK h gt PACSDK lib gt If I 7K I 87K PWM modules is used on XPAC series device you need to include or plug in the files below gt PACSDK PWM h gt PACSDK PWM lib How to create a program with new SDK using Microsoft Embedded Visual C eVC Step
87. BOOL ret HANDLE hOpen char buf Length hOpen uart_Open COM1 9600 N 8 1 ret uart_ SendCmdExt hOpen SOOM 4 buf Length SOOM ask the device name uart_Close hPort C bool ret IntPtr hOpen string buf S01M byte cmd new byte 64 byte result new byte 64 hOpen PACNET UART Open COM1 9600 N 8 1 cmd PACNET MISC AnsiString buf ret PACNET UART SendCmdExt hOpen cmd 64 result 64 Remarks This function calls PurgeComm to clear serial COM port input and output buffer Refer to Remarks of uart_SendExt uart_RecvExt for more details PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 212 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 8 uart SetTimeOut This function sets the time out timer Syntax C void uart_SetTimeOut HANDLE hPort DWORD msec int ctoType Parameters hPort in Handle to the open COM port msec in Millisecond to the timer cto Type in Specifies the time out timer type as following CTO_TIMEOUT_ALL O CTO_READ_RETRY_TIMEOUT 1 CTO_READ_TOTAL_TIMEOUT 2 CTO WRITE TOTAL TIMEOUT 3 Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 213 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C HANDLE hOpen DWORD mes hOpen uart_Open COM1 9600 N 8 1 me
88. CNET UART Open byte iSlot 2 int iDI TotalCh 8 uint IDI Value bool iRet PACNET IO ReadDI MF hPort iSlot iDl_ TotalCh ref IDI Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 262 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 6 pac ReadDIO pac ReadDIO MF This function reads the DI and the DO values of the DIO module Syntax C for pac_ReadDIO BOOL pac_ReadDIO HANDLE hPort int slot int iDI TotalCh int iDO_TotalCh DWORD IDI Value DWORD IDO Value C for pac ReadDlO_MF BOOL pac_ReadDIO_MF HANDLE hPort int slot int iDl TotalCh int iDO_TotalCh DWORD IDI Value DWORD IDO Value PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Page 263 E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 DI_ TotalCh
89. Ch in The total number of the AO channels of the AO module float fValue in The AO value to write to the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 290 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_WriteAO Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteAO hPort iSlot iChannel iAO_ TotalCh fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue 5 BOOL iRet pac_WriteAO O iSlot iChannel iAO TotalCh fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 291 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_WriteAO If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue 5 bool iRet PACNET IO WriteAO hPort iSlot Channel AO_TotalCh fValue PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use
90. Char data type for the current application Syntax C bool pac_GetCurrentDirectory char cBuffer DWORD nSize Parameters cBuffer out A pointer to a buffer that receives the current directory nsize in A pointer to a variable that specifies the size in chars of the buffer Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call GetLastError to obtain the last error ocde of Windows API PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 451 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C char buf 1024 pac_GetCurrentDirectory buf 1024 CH string str str PACNET MISC GetCurrentDirectory PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 452 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 7 pac_GetCurrentDirectoryW This function retrieves the current directory of the TCHAR data type for the current application Syntax C bool pac _GetCurrentDirectoryW LPTSTR cBuffer DWORD nSize Parameters LPTSTR out A pointer to a buffer that receives the current directory nsize in A pointer to a variable that specifies the size in TCHARs of the buffer Return Value If the function succeeds the return value is TRUE If the function fails the return val
91. Co Ltd All Rights Reserved E mail service icpdas com PAC_IO Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 464 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac_ReadCNT Y pac_ClearCNT Y pac_ReadCNTOverflow WriteModuleSafeValueDO MF eadModuleSafeValueDO MF pac_WriteModulePowerOnValueDO p ac_WriteModulePowerOnValueDO M F lt lt lt pac_ReadModulePowerOnValueDO p ac_ReadModulePowerOnValueDO_M F lt lt lt pac_WriteModuleSafeValueAO PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 465 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac_InitModuleWOTinterrupt pac_GetModuleWDTinterruptstatu pac_SetModuleWDTinterruptstatu PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 466 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com PWM Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_SetPWMDuty pac _GetPWMDuty pac SetPWMFrequency pac _GetPWMFrequency pac SetPWMMode Y fpaccepwmmodce Y YF Ll o IL o os os pac SetPwMDitriggerconfig Y YF YT LOT paccewmortiggerconig Y Y YL I o poro pac_SetPWMSStart pac GePWMWmhml Y YF Ll I
92. DLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 406 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac SavePWMConfig hPort iSlot uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 bool iRet PACNET PWM SavePWMConfig hPort iSlot PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 407 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 14 pac GetPWMDIOStatus This function reads the status of the PWM output port and the digital input port Syntax C bool pac GetPWMDIOStatus HANDLE port int slot unsigned char pwmBitArr unsigned char diBitArr Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remot
93. E_FAIL PAC_ERR_MEMORY_BASE 6 PAC_ERR_EEP_READ FAIL PAC_ERR_MEMORY_BASE 7 UART PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW PAC_ERR_UART_BASE 9 0 PAC_ERR_IO_DO_CANNOT_OVERWRITE PAC_ERR_IO_BASE 10 PAC_ERR_IO_ AO CANNOT OVERWRITE PAC_ERR_IO_BASE 11 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 491 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix D Using the Multi function DCON module 1 On WinPAC devices i _ The users have used WinPAC series devices and their programs is based on the old SDK WinPacSDK dll WinPacNet dll working with the old DCON modules Note 2 on WinPAC device and without using multi function DCON modules Note 1 The user s program can continue to use the old library without needing to be modified The Old SDK will continue to maintain Fix the bugs and released regularly but will not add new features Use the old SDK as following flowchart The VC project required to link WinPacSDK lib while building and the built executable file placed in the WinPAC series device must work with WinPacSDK dll VC Project Link C EXE ARM WinPacSDK lib PC WinPAC The CH VB net project required to refer to WinPacNet dll while building and the built executable file placed in the WinPAC series device must work with WinPacNet dll and WinPacSDK dll C VB net A Project Refer to WinPacNet dll WinPacSDK dll
94. Environment The OS of XPAC series is Windows CE 6 0 and OS of WinPAC series is Windows CE5 0 Different from development tools of XPAC and WinPAC series XPAC supports Visual Studio 2005 2008 and in addition to support Visual studio 2005 2008 WinPAC supports Embedded Visual C eVC PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 22 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 1 C C MFC based on Visual Studio for XPAC series Required header and library files The following list lists the libraries header files or DLL files you will need to include to develop a XPAC application or plug in gt gt gt PACSDK h PACSDK lib If 1 7K 1 87K PWM modules is used on XPAC series device you need to include or plug in the files below PACSDK_PWM h PACSDK_PWM lib How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Toole Test Window Help M Project Cte Shift Web Site Shift AlN H Hie CtHN Project From Existing Code save All Ctltshattte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 23 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select Smart Device New Project eee Templates NET Framework 3 5 JHE Yisual Studio inst
95. I Manual v1 1 1 Last Revised Dec 2013 Page 420 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 4 _ pac _SetBPTimerOut This function creates a hardware timer with the specified time out value of high low wave The time out value of high low wave are specified and every time the time out of high wave and low wave occur the system posts an interrupt signal to the system and the pass the message to an application defined callback function The timerout pin on each slot will be triggered while a timerout signal has been outputted The timeourput pin can be used to acquire the synchronized data on each slot Low wave time out gt Timerout Pin signal gt High wave time out Interrupt Signal Syntax C bool pac SetBPTimerOut unsigned int uHighElapse unsigned int uLOwElapse pac TIMEROUT CALLBACK FUNC f PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 421 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters uHighElapse in Specifies the elapsed time value for a high wave of the timerout signal as integer from 0765535 in microseconds uLOwElapse in Specifies the elapsed time value for a low wave of the timerout signal as integer from 0765535 in microseconds Specifies the address of the application supplied f callback function Return Value If the function succeeds the return value is TRUE
96. ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 Backplane Timer API Backplane timer API supports to hardware timer including timerout timer1 timer2 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 414 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the backplane timer functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 5xxx VP 25Wx VP 23Wx pac GetBPTimerTimeTick ms Y Yo or oo pac GetBPTimerTimeTick_us pac_SetBPTimer pac_SetBPTimerinterruptPriority pac_KillBPTimer PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 415 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Backplane Timer Functions The following functions are used to retrieve or set the backplane timer PACSDK Functions PACNET Functions Description Returns the number of milliseconds have elapsed since the system was pac_GetBPTimerTimeTick ms BPTimer GetBPTimerTimeTick_ ms started excluding any time that the system was suspended Returns the number of microsecond have elapsed since the system was pac_GetBPTimerTimeTick_us BPTimer GetBPTimerTimeTick_us started excluding any time that the system was suspended pac_SetBPTimer BPTimer SetBPTimer Creates a hardware timer with the specified time out value pac_SetBPTimerOut BPTimer SetBP
97. Last Revised Dec 2013 Page 46 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 PAC API Functions The PACSDK API consists of the following APIs and functional categories e System Information e Backplane Access e Interrupt e Memory Access e Watchdog UART Local I O PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 47 Remote I O Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 System Information API The system information functions and messages describe or change the system configuration settings and attributes PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 48 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the system information functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_GetRotarylD Y Y Y Y Y Y ppaccetsokversion Y 3 oyy o A pac Changestot YY o ro vv pac CheckSDKVersion Y o ro o pac_ModuleEx sts J Y o s o y o Y Y Y Y Y Y Y Y Y Y Y Y u Y Y lt lt lt lt lt lt lt lt lt lt lt lt pac Getosversion Y Y o oy pac GetMacadaress yo Jo Y J y J y C Y Y Y lt lt lt lt lt lt lt
98. O ReadDO Reads the DO value of the DO module PAC_IO ReadDO MF pac_ReadDI pac_ReadDI_ MF PAC_IO ReadDI Reads the DI value of the DI module PAC_IO ReadDI MF pac_ReadDIO pac_ ReadDIO MF PAC_IO ReadDIO Reads the DI and the DO values of the DIO module PAC_IO ReadDIO MF pac ReadDICNT pac_ReadDICNT MF PAC_IO ReadDICNT Reads the counts of the DI channels of the DI module PAC_IO ReadDlCNT_MF pac_ClearDICNT pac_ClearDICNT_MF PAC IO ClearDlCNT Clears the counter value of the DI channel of the DI module PAC_10 ClearDICNT_MF pac_WriteAO pac_WriteAO_MF PAC 10 WriteAO Writes the AO value to the AO modules PAC_IO WriteAO_MF pac_ReadAO PAC IO ReadAO Reads the AO value of the AO module pac_ReadAl PAC 10 ReadA Reads the engineering mode Al value of the Al module pac_ReadAlHex PAC 10 ReadAlHex Reads the 2 s complement mode Al value of the Al module pac_ReadAlAllExt PAC IO ReadAlAllExt Reads all the AI values of all channels in engineering mode of the Al module pac_ReadAlAll PAC IO ReadAlAll Reads all the Al values of all channels in engineering mode of the Al module pac_ReadAlAllHexExt PAC_10 ReadAlAllHexExt Reads all the Al values of all channels in 2 s complement mode of the Al module pac_ReadAlAllHex PAC IO ReadAlAllHex Reads all the Al values of all channels in 2 s complement mode of the Al module pac _ReadCNT PAC IO ReadCNT Reads the counter values of the counter freguency modules pac_ClearCNT PAC IO ClearCN
99. OOL pac_ClearDlOLatch HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 278 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac_ClearDIOLatch hPort iSlot uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 BOOL iRet pac_ClearDlOLatch O iSlot CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 bool iRet PACNET IO ClearDlOLatch hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 279 Copyright 2013 ICP DAS Co Ltd All Rig
100. PI Manual v1 1 1 Last Revised Dec 2013 Page 106 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 2 pac _UnregisterSlotinterrupt This function unregisters slot interrupt service route and disables a hardware interrupt as specified by its interrupt identifier Syntax C BOOL pac _UnregisterSlotInterrupt BYTE slot Parameters slot in Specifies the index of slot Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 107 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something pac_InterruptDone slot return false if return true SDK will do pac_InterruptDone automatically else users should do pac InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or flase needn t add pac InterruptDone and it will work correctly void ClntrDlg OnButton1 pac_RegisterSlotinterrupt slot slot_callback_ proc pac EnableSlotinterrupt slot true _ enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false disable slot interrupt pac_UnregisterSlotInterrupt slot
101. PWMPulseCount This function reads the PWM step value for a specific channel Syntax C bool pac GetPWMPulseCount HANDLE port int slot short chindex long cnt Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel cnt out The PWM steps 0x0001 to OxFFFF When set to more than 1 step the PWM continuous mode will be automatically set to disabled PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 412 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 long Icnt BOOL iRet pac_GetPWMPulseCount hPort iSlot iChannel amp lcnt uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 long Icnt bool iRet PACNET PWM GetPWMPulseCount hPort iSlot iChannel ref Icnt PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 413 Copyright 2013
102. Port uart_Open COM5 115200 N 8 1 BOOL ret uart_GetLineStatus hPort DSR the pin DSR for example if ret printf The status of DSR is ON n else printf The status of DSR is OFF n uart_Close hPort CH IntPtr hPort PACNET UART Open COM5 115200 N 8 1 the pin DSR for example bool ret PACNET UART GetLineStatus hPort DSR if ret Console WriteLine The status of DSR is ON else Console WriteLine The status of DSR is OFF PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 228 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 15 uart GetDataSize This function retrieves the number of bytes received by the serial provider but not yet read by a uart_Recv operation or of user data remaining to transmitted for write operations Syntax C BOOL uart_GetDataSize HANDLE hPort int data_type Parameters hPort in Handle to the open COM port data_type in A value specifies to retrieve in or out buffer This parameter can be following values Hdefine IN DATA O Hdefine OUT DATA 1 Return Value The number of bytes in out buffer but not yet read write PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 229 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 16 uart SetLineStatus This function sets the status of
103. ReadDO MF pac_ReadDl pac ReadDI MF pac_ReadDlO pac ReadDlO MF pac _ReadDlLatch pac_ClearDlLatch pac_ReadDlOLatch pac_ClearDlOLatch pac_ReadDICNT pac_ReadDICNT_MF pac_ClearDICNT pac_ClearDICNT_MF pac _WriteAO pac_WriteAO_MF pac ReadAO pac_ReadAl pac_ReadAlHex pac_ReadAlAllExt pac_ReadAlAll pac_ReadAlAllHexExt pac_ReadAlAllHex pac_ReadCNT pac_ClearCNT pac_ReadCNTOverflow pac_WriteModuleSafeValueDO pac_WriteModuleSafeValueDO MF pac_ReadModuleSafeValueDO pac_ReadModuleSafeValueDO_MF 251 255 259 263 268 272 274 278 280 285 289 293 297 301 305 309 311 315 318 321 323 326 331 pac WriteModulePowerOnValueDO pac_WriteModulePowerOnValueDO_MF336 pac_ReadModulePowerOnValueDO pac_ReadModulePowerOnValueDO_MF 342 pac_WriteModuleSafeValueAO pac_ReadModuleSafeValueAO Last Revised Dec 2013 Page E mail service icpdas com 346 348 2 8 2 7 30 2 7 31 2 7 32 2 7 33 2 7 34 241 99 2 7 36 2 7 37 2 7 38 2 7 39 2 7 40 2 8 1 2 8 2 2 8 3 2 8 4 2 8 5 2 8 6 2 9 7 2 8 8 2 8 9 2 8 10 2 8 11 2 8 12 2 8 13 2 8 14 2 8 15 PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved PWM API pac_WriteModulePowerOnValueAO pac_ReadModulePowerOnValueAO pac_GetModuleLastOutputSource pac_GetModuleWDTStatus pac_GetModuleWDTConfig pa
104. T Clears the counter values of the counter freguency modules pac_ReadCNTOverflow PAC IO ReadCNTOverflow Clears the counter overflow value of the counter freguency modules pac_WriteModuleSafeValueDO PAC _IO WriteModuleSafeValueDO Writes the DO safe values to DO modules pac_WriteModuleSafeValueDO_MF PAC_IO WriteModuleSafeValueDO MF pac_ReadModuleSafeValueDO PAC_IO ReadModuleSafeValueDO Reads the safe value of the DO modules pac_ReadModuleSafeValueDO_MF pac IO ReadModuleSafeValueDO MF PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 240 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac_WriteModulePowerOnValueDO PAC IO WriteModulePowerOnValueDO Writes the DO power on values to DO modules pac_WriteModulePowerOnValueDO_ pac 10 WriteModulePowerOnValueDO MF MF pac_ReadModulePowerOnValueDO PAC_IO ReadModulePowerOnValueDO Reads the power on value of the DO modules pac_ReadModulePowerOnValueDO_ pac IO ReadModulePowerOnValueDO MF MF pac_SetModuleWDTConfig PAC 10 SetModuleWDTConfig Enables disables the host watchdog and sets the host watchdog timeout value of a module pac_ResetModuleWDT PAC_IO ResetModuleWDT Resets the host watchdog timeout status of a module pac_RefreshModuleWDT PAC_IO RefreshModuleWDT Refreshes the watchdog pac_InitModuleWDTInterrupt PAC_10 InitModuleWDTInterrupt Initializes and enables interrupt of a module watchdog pac_GetModuleWDTInterrup
105. T ErrHandling GetLastError ToString n return Remarks PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 436 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com The pac_GetErrorMessage function can be used to obtain error message strings for the XPac error codes returned by pac_GetLastError as shown in the following example TCHAR Buffer 32 pac GetErrorMessage pac_ GetLastError Buffer MessageBox NULL Buffer L Error MB_OK MB_ICONINFORMATION PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 437 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 10 4 pac_ClearLastError This function clears the last error code Syntax C void pac ClearLastError Parameters This function has no parameters Return Value This function has does not return a value Examples This function has no examples Remarks The pac_ClearLastError function clears the last error that is the application is treated as SUCCESS PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 438 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 Misc API Supported PACs The following list shows the supported PACs for each of the Misc functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx WideStringToAnsi
106. T Open int total channel 8 uint do_ value 4 turn on the channel two bool ret PACNET IO pac WriteModuleSafeValueDO hPort 1 total channel do_value PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 330 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac_WriteModuleSafeValueDO_MF Example 1 1f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uintdo_value 4 turn on the channel two bool ret PACNET IO pac WriteModuleSafeValueDO MF hPort PACNET IO REMOTE_IO 1 total channel do_ value PACNET UART Close hPort Example 2 If the module is 87k local IntPtr hPort hPort PACNET UART Open int total_ channel 8 uint do value 4 turn onthe channel two bool ret PACNET IO pac WriteModuleSafeValueDO MF hPort 1 total channel do_value PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 201
107. T imerOut Creates a hardware timer with the specified time out value of high low wave pac_SetBPTimerlnterruptPriority BPTimer SetBPTimerlnterruptPriority Sets the priority for a real time thread of the backplane timer BPTimer KillBPTimer Destroys the specified timer event identified by type set by an earlier call to pac KillBPTimer pac_SetBPTimer PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 416 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 1 pac_GetBPTimerTimeTick_ms This function returns the number of milliseconds have elapsed since the system was started excluding any time that the system was suspended Syntax C DWORD pac_GetBPTimerTimeTick_ms void Parameters This function has no parameters Return Value The number of milliseconds indicates success Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 417 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 2 pac GetBPTimerTimeTick_us This function returns the number of microsecond have elapsed since the system was started excluding any time that the system was suspended Syntax C DWORD pac_GetBPTimerTimeTick us void Parameters This function has no parameters Return Value The number of microseconds indicates success Examples This function has no examples PAC Stan
108. TotalCh index PACNET UART Close hPort Remarks The function is used the same as v amp 1 lt lt index PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 244 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 2 pac WriteDO pac WriteDO_ MF This function writes the DO values to DO modules Syntax C for pac WriteDO BOOL pac WriteDO HANDLE hPort int slot int iDO TotalCh DWORD IDO Value C for pac_WriteDO MF BOOL pac WriteDO_MF HANDLE hPort int slot int iDO TotalCh DWORD IDO_ Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 245 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 iDO_ TotalCh in The total number of DO channels of the DO modules iDO Value in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return val
109. ViewPAC Series The following table shows the defined values Value Description CSSS No module existed 0x80 Genernal 8000W module 0x81 8000RW module R version Provide PowerOn and Safe value CE oet rene module t verson Provade Poweron ant vaner oen roo mouie tarea 00 damnes mo nomom Y O O OxC2 8000W module with 8 DI channels and 8 DO channels 0x40 No module defined For WinPAC 5000 Series The following table shows the defined values Value Description CITE EE OxCO XW board with 16 DO channels OxC2 XW board with 8 DI channels and 8 DO channels 0x40 No XW board defined XW board with 16 DI channels PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 83 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int iDIO_ Slot 1 int Type O Type pac GetModuleType iDIO Slot if Type Oxe2 Type 0xc2 The module is DIO module C byte slot 1 int ModuleType 0 ModuleType PACNET Sys GetModuleType slot if ModuleType Oxe2 ModuleType Oxc2 The module is DIO module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 84 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 18 pac GetPacNetVersion This function retrieves the version number of the PACNET dll Syntax C void pac_GetPacNetVersion LPSTR dil_ version Param
110. WDT_HW O PAC WDT_ OS 1 PAC WDT_ HW and PAC WDT_ OS are different definitions of the name two Watchdog timers are electronic timers which has hardware reset circuit that monitors the operating status of the module value in Specifies the watchdog time Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 144 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail Examples C DWORD second 1000 bool ret ret pac EnableWatchDog PAC WDT_ OS second CH uint second 1000 bool ret_err ret_err PACNET Sys WDT EnableWatchDog 1 second Remarks OS watchdog The unit of the second parameter of the OS watchdog is second for XPAC series only The maximum of second parameter of the OS watchdog is 1321 seconds about 22 minutes for WinPAC series only The maximum of second parameter of the OS watchdog is 1321 seconds about 22 minutes Hardware watchdog for XPAC series only The hardware watchdog second parameter is a value which is between 1763 un
111. WORD do value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO hPort 1 total channel do value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 328 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac WriteModuleSafeValueDO MF Example 1 1f the module is remote HANDLE hPort hPort uart Open COM2 9600 N 8 1 int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO MF hPort PAC REMOTE IO 1 total channel do_value uart_Close hPort Example 2 If the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO MF hPort 1 total channel do_ value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 329 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_WriteModuleSafeValueDO Example 1 1f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 4 turn on the channel two bool ret PACNET IO pac_WriteModuleSafeValueDO hPort PACNET IO REMOTE_IO 1 total channel do value PACNET UART Close hPort Example 2 If the module is 87k local IntPtr hPort hPort PACNET UAR
112. XPAC WinPAC and ViewPAC series PACSDK has replaced XPACSDK and WinPACSDK ICP DAS has released a new SDK PACSDK which merged and replaced the XPACSDK and WinPACSDK XPACSDK WinPACSDK PAC SDK The XPAC WinPAC SDK has been unified and renamed PACSDK The new PACSDK dll provides support for two platforms one being designed for the WinPAC series ARM platforms and the other for the XPAC series x86 platforms PACSDK dll x86 is linked to C programs for the XPAC series to replace the previous SDK XPACSDK_CE dll and PACSDK dll ARM is linked to C programs for the WinPAC series to replace the previous SDK WinPACSDK dll PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 16 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com The PACNET dll is used for Net CF programs CH VB for both the XPAC and WinPAC series to replace the previous SDKs XPacNet dll and WinPacNet dll New Previous SDK files comparison items WinPACSDK Library XPACSDK CE6 Library PACSDKLibrary PACSDK h Development header files WinPacSDK h XPacSDK_CE h PACSDK_PWM h PACSDK lib Development library files WinPacSDK lib XPacSDK_CE lib PACSDK_PWM lib PACSDK dll Target device Native DLL files WinPacSDK dll XPacSDK CE dll PACSDK PWM dll Target device NET CF DLL files WinPacNet dll XpacNet dll PACNET dll Benefits of the unified SDK include Easily migrates custom WinPAC programs to the XPAC
113. XPAC W inPAC Standard API User Manual WinCE Based eVC amp NET Version 1 1 1 December 2013 Service and usage information for XPAC 8000 WinPAC 8000 ViewPAC 2000 WinPAC 5000 Written by Sean Edited by Anna Huang Warranty All products manufactured by ICP DAS are under warranty regarding defective materials for a period of one year beginning from the date of delivery to the original purchaser Warning ICP DAS assumes no liability for any damage resulting from the use of this product ICP DAS reserves the right to change this manual at any time without notice The information furnished by ICP DAS is believed to be accurate and reliable However no responsibility is assumed by ICP DAS for its use not for any infringements of patents or other rights of third parties resulting from its use Copyright Copyright 2013 by ICP DAS Co Ltd All rights are reserved Trademark The names used for identification only may be registered trademarks of their respective companies Contact US If you have any problem please feel free to contact us You can count on us for guick response Email service icpdas com PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Contents COMP 3 ADOGL IS QUISO it 12 Getting Started cd 16 1 1 introducing the PACSDK 2 4a dd id iii 16 1 2 Installing the PAC SD
114. ableLEDs This function sets the state of the specified LED Syntax C void pac EnableLEDs int pin bool bFlag Parameters pin Specifies the LED O LT LED 1 L2 LED bFlag Specifies the mode of the LED True Turn on the LED False Turn off the LED Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 74 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_EnableLED 0 TRUE CH PACNET Sys EnableLEDs 0 true PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 75 Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 14 pac_BackwardCompatible This function determines whether the operating system work in backward compatible mode or not Syntax C bool pac BackwardCompatible Parameters This function has no parameters Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError Remark The function is only applied to the WP 8000 sereis and it is used for back compatible with old PAC controller WinCon series PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 76 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool bBC bBC
115. ac_ReadDIO hPort iSlot iDI TotalCh DO TotalCh amp IDI Value amp IDO Value uart_Close hPort CH pac_ReadDIO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iDl_ TotalCh 8 int iDO TotalCh 8 uint IDI Value uint IDO Value bool iRet PACNET IO ReadDlO hPort iSlot iDl_ TotalCh iDO_ TotalCh ref IDI Value ref IDO Value PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 266 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ReadDIO_MF If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iDl_ TotalCh 8 int iDO TotalCh 8 uint IDI Value uint IDO Value bool iRet PACNET IO ReadDlO MF hPort iSlot iDI TotalCh iDO TotalCh ref IDI Value ref IDO Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 267 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 7 pac ReadDllLatch This function reads the DI latch value of the DI module Syntax C BOOL pac ReadDlLatch HANDLE hPort int slot int
116. ail service icpdas com 2 4 5 pac GetWatchDogTime This function retrieves the watchdog time Syntax C DWORD pac_GetWatchDogTime int wdt Parameters wat in Specifies the Watchdog type PAC WDT_HW O PAC WDT OS 1 Return Value The return value is the watchdog time which has been assigned by pac_EnableWatchDog or pac_SetWatchDogTime The unit of return value is second for OS watchdog value which is between 063 for hardware watchdog PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 153 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C DWORD dwTime dwTime pac_GetWatchDogTime PAC_WDT_OS C uint uTime uTime PACNET Sys WDT GetWatchDogTime 1 Remarks for WinPAC series only The same as the pac_EnableWatchDog function the pac_GetWatchDogTime of hardware watchdog retrieves a value between 0 31 but millisecond PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 154 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 6 pac SetWatchDogTime This function starts a watchdog operation The hardware watchdog second Parameter is a value which is between 0 63 unit A unit is about 0 5 seconds O means the shortest timeout otherwise 63 is longest which is about 30 seconds Syntax C bool pac SetWatchDogTime int wat DWORD value Parameters wat in Specifies the
117. al port HANDLE opened by uart_Open If the IO module is at local this parameter must be 0 Slot in The slot in which module is to check exists or not If the IO module is at remote this parameter is a value of IO module ID Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 64 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C if you want to check a module which is in the slot 5 BOOL bExist bExist pac ModuleExists O 5 if bExist MessageBox The module exist else MessageBox The module unexist C if you want to check a module which is in the slot 5 bool bExist bExist PACNET Sys ModuleExists O 5 if b Exist MessageBox show The module exist else MessageBox show The module unexist PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 65 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 8 pac GetOSVersion This function retrieves the version number of the current operating system OS Syntax C void pac GetOSVersion LPSTR os_ version Parameters os_version out The version number of the OS Return Value This function does not re
118. all pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret DWORD indexzO TCHAR strName 10 ret pac_RegGetKeyBylndex TEXT HKEY_USERS myKey index strName C bool ret uint index 0 string strName new String 0 10 ret WinPAC RegGetKeyBylndex HKEY_ USERS myKey index strName PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 173 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 8 pac_RegGetKeylnfo This function retrieves the type of specified index of registry key Syntax C DWORD pac_RegGetKeyInfo LPCTSTR KeyName Parameters KeyName in Specific the path of registry key Return Value We define four types about the return value PKT_NONE O PKT_KEY 1 PKT_STRING 2 PKT_DWORD 3 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 174 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C DWORD dwType dwType pac_RegGetKeylnfo TEXT HKEY_USERS myKey value C uint uType
119. alled templates qu ATL Smart Device Project a MFC Smart Device ActiveX Control aig MFC Smart Device Application af MFC mart Device DLL al Win32 Smart Device Project My Templates nat Device search Online Templates Other Project Types F Test Projecte An application for Windows Mobile and other Windows CE based devices that uses the Microsoft Foundation Class Library ame Location Souion Nae E Cnt distor fo suo Platforms Overview Select platform SDKs to be added to the current project Platforms Application Type Installed SDKs Selected SDKs Pocket PC 2003 XPacs5DK CE User Interface Features Smartphone 2003 Platform Builder Advanced Features PAC270 Generated Classes Document Template Strings XPacs5DK_CE Instruction sets Keo PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 24 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 4 On the configuration toolbar select the XPacSDK_CE x86 Example Microsoft Visual Studio File Edit View Project Buld Debug Format Tools Test Window Help al ha i ha LS a al fa Ll J a Ea j Debug T PacSDE CE 560 r 10 XPacSDK_CE x86 Device all d n PE le Sh ur au SS bi ote a Frans m U Step 5 Include PACSDK h Hinclude PACSDK h include ztdafx h include bllEImformation h include elEInformationllez h include FPACSIE H Step 6 Include P
120. alue 4 turn on the channel two BOOL ret pac WriteDO MF hPort PAC REMOTE IO 1 total channel do_value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 _ turn on the channel two BOOL ret pac WriteDO MF hPort 1 total channel do_value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 248 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac_WriteDO Example 1 1f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 4 turn on the channel two bool ret PACNET IO WriteDO hPort PACNET IO REMOTE_IO 1 total channel do value PACNET UART Close hPort Example 2 If the module is 87k local IntPtr hPort hPort PACNET UART Open int total channel 8 uintdo value 4 turn onthe channel two bool ret PACNET IO WriteDO hPort 1 total channel do_ value PACNET UART Close hPort Example 3 If the module is 8k local int total channel 8 uintdo_value 4 _ turnonthe channel two bool ret PACNET IO WriteDO 0 1 total channel do_value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 249 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac WriteDO MF
121. ample 2 If the module is 87k local IntPtr hPort PACNET UART Open int total channel 8 uintdo value 4 turn on the channel two bool ret PACNET IO pac WriteModulePowerOnValueDO MF hPort 1 total channel do_value PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from 0 to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 341 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 27 pac ReadModulePowerOnValueDO pac_Rea dModulePowerOnValueDO MF This function reads the power on value of the DO modules Syntax C for pac ReadModulePowerOnValueDO BOOL pac ReadModulePowerOnValueDO HANDLE hPort int slot int iDO TotalCh unsigned long lValue C for pac ReadModulePowerOnValueDO MF BOOL pac_ReadModulePowerOnValueDO MF HANDLE hPort int slot int iDO_TotalCh unsigned long IValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 342 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The ser
122. annelzO int iOverflow BOOL iRet pac ReadCNT_ Overflow hPort iSlot iChannel amp iOverflow uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int Channel 0 int iOverflow BOOL iRet pac ReadCNT Overflow 0 iSlot iChannel amp iOverflow PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 324 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannelzO int iOverflow bool iRet PACNET IO ReadCNT_ Overflow hPort iSlot iChannel ref Overflow PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 325 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 24 pac_WriteModuleSafeValueDO pac_WriteMo duleSafeValueDO_MF This function writes the DO safe values to DO modules Syntax C for pac_WriteModuleSafeValueDO BOOL pac WriteModuleSafeValueDO HANDLE hPort int slot int iDO TotalCh DWORD IValue C for pac WriteModuleSafeValueDO MF BOOL pac_WriteModuleSafeValueDO MF HANDLE hPort int slot int iDO_TotalCh
123. as com Examples C bool ret ret pac_RegSetString TEXT HKEY_USERS myKey value TEXT Hello exe 2 wcslen TEXT Hello exe sizeof TCHAR 2 C bool ret ret WinPAC RegSetString HKEY_USERS myKey value Hello exe 2 uint Hello exe Length PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 185 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 14 pac_RegSetDWORD This function assigns the specified registry key data whose type is DWORD Syntax C bool pac RegSetDWORD LPCTSTR KeyName DWORD assignVal Parameters KeyName in Specific the path of registry key which you want to assign data assignStr in Specific the data Return Values Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 186 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_RegSetDWORD TEXT HKEY_USERS myKey value 40 C bool ret ret WinPAC RegSetDWORD HKEY_USERS myKey value 40 PAC Standard API Manual v1 1 1 Last Revised
124. ase use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AI value from the channel Al_ TotalCh in The total number of the AI channels of the AI module iValue in The pointer to the AI value that is read back from the AI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 302 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAl_ TotalCh 8 int iValue BOOL iRet pac_ReadAlHex hPort iSlot iChannel iAl_TotalCh amp iValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAl_ TotalCh 8 int iValue BOOL iRet pac_ReadAlHex 0 iSlot iChannel iAl_TotalCh amp iValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 303 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAl_ TotalCh 8 int iValue bool iRet PACNET IO ReadAlHex hPort iSlot iChannel iAl_ TotalCh ref iValue PACNET UART Close hPort Remarks The function can support for Local or Remote Whe
125. ast Revised Dec 2013 Page 501 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 4 XP 8341 Atom CE6 XP 8741 Atom CE6 A COM4 a RS 232 RS 485 ZZ i D L COM5 RS 232 COM2 RS 232 E a XP 8341 Atom CE6 COM1 Slot 1 3 XP 8741 Atom CE6 COM1 Slot 1 7 COM3 0 RS 485 L 0 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 502 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 5 WP 81x1 D COM2 D RS 485 GHD TD 7 COM1 _ RS 232 A LRU A E i a E E d COMO Slot 0 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 503 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 6 WP 84x1 WP 88x1 COM3 COM4 RS 232 RS 485 RS 232 COM RS 232 WP 84x1 COMO Slot 0 3 WP 88x1 COMO Slot 0 7 gt cOM2 D all PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 504 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 7 WP 5141 WP 5141 OD LEL SIL TI bs TE a8 i J LF 4 O 180 1 1808 1 08 0080 0 a a IA o A MEE ELECO FWS Peo Ez L JLILJ COM1 COM2 COM3 RS 232 RS 485 RS 232 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 505 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
126. c WriteMemory This function stores data in the specified memory Syntax C BOOL pac _WriteMemory DWORD address LPBYTE lpBuffer DWORD dwLength int mem type PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 128 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters Address in Specifies the memory address where write from EEPROM O Ox1FFF 8KB for users Ox2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system loBuffer in A pointer to the buffer containing the data to be written to the memory dwLength in Number of characters to be written mem_type in Handle to a currently type memory PAC_MEM_SRAM O WP 5000 series doesn t support SRAM PAC MEM EEPROM 1 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 129 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C
127. c_ReadAlAllHexExt pac_ReadAlAllHex pac_ReadCNT pac_ClearCNT pac_ReadCNTOverflow pac_WriteModuleSafeValueDO pac_Write ModuleSafeValueDO_MF pac_ReadModuleSafeValueDO pac_ReadM oduleSafeValueDO_MF pac_WriteModulePowerOnValueDO pac_W riteModulePowerOnValueDO_MF pac_ReadModulePowerOnValueDO pac_Re adModulePowerOnValueDO_MF pac_WriteModuleSafeValueAO pac_ReadModuleSafeValueAO pac_WriteModulePowerOnValueAO pac_ReadModulePowerOnValueAO pac_GetModuleLastOutputSource pac_GetModuleWDTStatus pac_GetModuleWDTConfig pac_SetModuleWDTConfig pac_ResetModuleWDT pac_RefreshModuleWDT pac_InitModuleWDTInterrupt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 237 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com des pr foe ebe redoedd oe Y Y Y Y Y Y Y Y S PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 238 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com PAC_lO Functions The following functions are used to retrieve or set the IO modules PACSDK Functions PACNET Functions Description pac_GetBit PAC 10 GetBit Retrieves the value which in specific bit pac_WriteDO pac WriteDO MF PAC_IO WriteDO Writes the DO values to DO modules PAC_10 WriteDO_MF pac_WriteDOBit PAC IO WriteDOBit Writes a single bit of value to the DO module that is only the channel corresponding to the bit is changed pac ReadDO pac ReadDO MF PAC_I
128. c_SetModuleWDTConfig pac_ResetModuleWDT pac_RefreshModuleWDT pac_InitModuleWDTInterrupt pac_GetModuleWDTInterruptStatus pac_SetModuleWDTInterruptStatus pac_SetPWMDuty pac_GetPWMDuty pac_SetPWMFreguency pac_GetPWMFreguency pac SetPWMMode pac GetPWMMode pac _SetPWMDITriggerConfig pac_GetPWMDITriggerConfig pac_SetPWMStart pac_SetPWMSynChanmnel pac_GetPWMSynChannel pac_SyncPWMStart pac_SavePWMConfig pac GetPWMDIOStatus pac SetPWMPulseCount Last Revised Dec 2013 Page 8 E mail service icpdas com 351 355 357 360 362 366 369 371 373 375 377 382 384 386 388 390 392 394 396 398 400 402 404 406 408 410 2 8 16 pac GetPWMPulseCount 412 2 9 Backplane imerAPliiiaia a nine a Od 414 2 9 1 pac GetBPTimerTimeTick ms 417 2 9 2 pac GetBPTimerTimeTick us 418 2 9 3 pac SetBPTimer 419 2 9 4 pac SetBPTimerOut 421 2 9 5 pac_SetBPTimerlnterruptPriority 423 2 9 6 pac KillBPTimer 425 2 20 Error Handling APl casacas 426 2 10 1 pac_GetLastError 429 2 10 2 pac_SetLastError 431 2 10 3 pac_GetErrorMessage 433 2 10 4 pac_ClearLastError 438 2 11 MISC did DRO GN Oia add and N wa ddaU 439 2 11 1 AnsiString 441 2 11 2 WideString 443 2 11 3 pac_AnsiToWideString 445 2 11 4 pac_WideToAnsiString pac_WideStringToAnsi 447 2 11 5 pac_DoEvent pac_DoEvents 449 2 11 6 pac_GetCurrentDirectory 451 2 11 7 pac_GetCurrentDirectoryW 453 Appendix A System Erro
129. cceeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 199 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C BOOL ret HANDLE hOpen hOpen uart_Open COM1 9600 N 8 1 ret uart_Close hOpen C bool ret IntPtr hOpen hOpen PACNET UART Open COM1 9600 N 8 1 ret PACNET UART Close hOpen Remarks The function for a specified COM port should not be used after it has been closed PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 200 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 3 uart SendExt This function sends data as a string through the COM port which has been opened When the checksum is enabled by using uart_EnableCheckSum function the two bytes of the checksum is automatically added to the string and the character OxOD is added to the end of the string to terminate the string buf This function replaces the uart_ Send function Syntax C BOOL uart_RecvExt HANDLE hPort LPSTR buf DWORD in_Len Parameters hPort in Handle to the open COM port buf in A pointer to a buffer that receives data out Len in A pointer to a variable that specifies the size in bytes of the buffer pointed to by the buf PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 201
130. ced in a single WinPacNet WinPAC xxx XPacNET XPac xxx class but the API functions for the PACNET dll are classified as PACNET sys PACNET Memory and PACNET Interrupt etc The classifications applied to the API functions for the PACNET dll as defined in the API user Sys PWM Last Revised Dec 2013 Page 481 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 API functions modification LED control API function pac_EnableLED Refer to pac_EnableLED reference of PACSDK dll modifications and updates for more details The modification in PACNET SDK XPacNet XPac pac_EnableLED pin bFlag function defined in XPacNet dll has been changed as PACNET SysInfo pac_EnableLEDs pin bFlag PACNET dll Add Registry API for XPAC series Refer to Add Registry API for XPAC series reference of PACSDK dll modifications and updates for more details The suite of the Registry API functions is placed in PACNET PAC_Reg class Add I O WDT PowerOn Safe Value API for pure DIO modules Refer to Add I O WDT PowerOn Safe Value API for pure DIO modules reference of PACSDK dll modifications and updates for more details The suite of the I O WDT PowerOn Safe Value API functions for pure DIO modules is placed in PACNET PAC_ IO class Add I O WDT PowerOn Safe Value API for the Multi function modules Refer to Add I O WDT PowerOn Safe Value API for Multi function modules reference of PACSDK dll m
131. ces using XPacNET to using PACNET using XPacNet Changed as using PACNET Modify the code for using XPAC series devices using WinPacNet to using PACNET using WinPacNet Changed as using PACNET In a VB net program Modify the code for using XPAC series devices Imports XPacNET to Imports PACNET Imports XpacNet Changed as Imports PACNET Modify the code for using XPAC series devices Imports WinPacNet to Imports PACNET Imports WinPacNet Changed as Imports PACNET PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 484 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com With the previous NETCF library WinPacNet dll or XPacNet dll the flowchart was as follows Project A net EXE WinPAC WinPacNet dll WinPacSDK dll Code Built as Linked with And Project B net EXE XPAC XPacNet dll XPacSDK_ CE dll Code Project A applied to WinPAC series modules and Project B applied to XPAC series modules are functionally identical but the source code cannot be exactly the same because of using the different NET CF library and few function name and error code are different So Project A and Project B are regarded as separate programs no relevance Project A for WinPAC series is built as an executable program which must be run with WinPacNet dll and WinPacSDK dll Project B for XPAC is built as an executable program wh
132. code string to ANSI or vice versa we should convert through byte array PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 442 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 2 WideString This function converts an ANSI byte array to Unicode string Syntax C string WideString byte CharStr Parameters CharStr in Points to the ANSI byte array to be converted Return Value Returns the Unicode string Examples C byte result new byte 32 IntPtr hPort PACNET UART Open COM1 115200 N 8 1 PACNET Sys ChangeSlot Convert ToByte 1 PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM result string str PACNET MISC WideString result PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 443 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks In NET if we want to convert a Unicode string to ANSI or vice versa we should convert through byte array PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 444 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 3 pac AnsiToWidesString This function converts an ANSI string to a Unicode string Syntax C void pac AnsiToWideString LPCSTR astr LPTSTR wstr Parameters astr in Points to the ANSI string to be converted wstr in A pointer to a buffer location that r
133. ction automatically adds the two checksum bytes to the string And then the end of sending string is further added 0x0D to mean the termination of the string buf Syntax C BOOL uart_Send HANDLE hPort LPSTR buf Parameters hPort in Handle to the open COM port buf in A pointer to a buffer that receives data Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 203 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C BOOL ret HANDLE hPort char buf 4 sprintf buf abcd hPort uart Open COM2 9600 N 8 1 ret uart_Send hPort buf uart_Close hPort C bool ret IntPtr hPort string buf buf abcd hPort PACNET UART Open COM2 9600 N 8 1 ret PACNET UART Send hPort WinPAC AnsiString buf PACNET UART Close hPort Remarks A string for buf cannot include space character within the string Otherwise the string will be stoped by space character For example SO1M 02 03 of the user defined string Howerver the actual string sent out is SO1M 0x0D The terminate characters is OxOD Refer to uart_SetTerminator function to change This function will call PurgeComm to clear serial COM port output buffer This function sends data with a terminate character OxOD For example
134. ction has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 117 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 10 pac_InterruptDone This function signals to the kernel that interrupt processing has been completed Syntax C void pac_ InterruptDone BYTE slot Parameters slot in Specifies the slot to clear trigger Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 118 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C HANDLE hintr BOOL bExit false BYTE slot 0 DWORD INTP_Thread PVOID pContext while bExit WaitForSingleObject hIntr INFINITE do something pac_InterruptDone slot pac _EnableSlotinterrupt slot false pac_SetSlotlnterruptEvent slot NULL CloseHandle pac_GetSlotInterruptEvent slot return O void ClnterruptDlg OnButton1 bExit true pac_Interruptinitialize slot pac_EnableSlotinterrupt slot true hintr pac_GetSlotinterruptEvent slot CreateThread NULL O INTP Thread amp slot O NULL PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 119 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 Memory Access API The memory access functions provide the memory management that may be used for reading w
135. ction or actions Watchdog operations include basic management operations such as turning on and refreshing The following topics describe how you can operate watchdog programmatically using the watchdog functions PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 141 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the Watchdog functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_EnableWatchDog pac_DisableWatchDog pac_RefreshWatchDog pac_GetWatchDogTime pac_SetWatchDogTime PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 142 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Watchdog Functions The following functions are used to retrieve or set the Watchdog PACSDK Functions PACNET Functions Description pac_EnableWatchDog Sys WDT EnableWatchDog Starts a watchdog operation pac_DisableWatchDog Sys WDT DisableWatchDog Stops a watchdog operation PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 143 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 1 _ pac EnableWatchDog This function starts a watchdog operation Syntax C BOOL pac_EnableWatchDog int wdt DWORD value Parameters wat in Specifies the name of watchdog PAC
136. ctions are used to retrieve or set the error code PACSDK Functions PACNET Functions Description pac_GetLastError ErrHandling GetLastError Returns the last error code value pac_SetLastError ErrHandling SetLastError Sets the last error code pac_GetErrorMessage ErrHandling GetErrorMessage Retrieves a message string pac_ClearLastError ErrHandling ClearLastError Clears the last error code PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 428 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 10 1 pac_GetLastError This function returns the last error code value Syntax C DWORD pac_GetLastError Parameters This function has no parameters Return Value The Return Value section of each function page notes the conditions under which the function sets the last error code Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 429 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks You should call the pac_GetLastError function immediately when a function s return value indicates that such a call will return useful data That is because some functions call pac_SetLastError 0 when they succeed wiping out the error code set by the most recently failed function For an example please refer to pac_GetErrorMerrage in this chapter To obtain an error string for XPAC error code
137. d All Rights Reserved E mail service icpdas com 2 10 3 pac_GetErrorMessage This function retrieves a message string Syntax C void pac GetErrorMessage DWORD dwMessagelD LPTSTR lpBuffer Parameters dwMessagelD in Specifies the 32 bit message identifier for the reguested message loBuffer out A pointer to a buffer that receives the error message Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 433 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int main int argc char argy if argc lt 3 printf usage ReadMemory address dwLength mem _ type n n printf Wwhere n printf address n printf the memory address where read from n printf dwLength n printf number of characters to be read n printf mem_type n printf 0 SRAM n printf 1 EEPROM n else BYTE buffer 4096 BOOL err char strErr 32 memset buffer 0 4096 if atoi argv 3 O printf The size of SRAM is d n pac_GetMemorySize atoi argv 3 err pac ReadMemory atoi argv 1 buffer atoi argv 2 atoi argv 3 if err FALSE pac GetErrorMessage pac GetLastError strErr printf Read SRAM failure The error code is x n pac_GetLastError printf s strErr return O printf s n buffer Copyright
138. d rate parity bits data bits and stop bits Syntax C HANDLE uart_Open LPCSTR ConnectionString PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 195 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters connectionString in Specifies the COM port baud rate parity bits data bits and stop bits The default setting is COM1 115200 N 8 1 The format of ConnectionString is as follows com_port baud_rate parity_bits data_bits stop_ bits Warning there is no blank space between each parameter Com_ port XPAC COM1 COM 2 WinPAC COMO COM1 baud_rate 1200 2400 4800 9600 19200 38400 57600 115200 parity_ bits N NOPARITY O ODDPARITY E EVENPARITY M MARKPARITY S SPACEPARITY Data_bits 5 6 7 8 Stop_ bits 1 ONESTOPBIT 2 TWOSTOPBITS 1 5 ONESSTOPBITS PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 196 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Values A handle to the open COM port Nonzero indicates success If the function fails the return value is INVALID HANDLE VALUE INVALID HANDLE_VALUE should be Oxffffffff in C C MFC INVALID HANDLE_VALUE should be 1 in NET To get extended error information call pac_GetLastError To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore i
139. dDlO MF pac_ReadDI MF pac ReadDO MF pac ReadDlO DIBit MF pac ReadDlO DOBit MF pac_ReadDIBit MF pac ReadDOBit MF pac_ReadDICNT MF pac_ClearDICNT MF pac_ReadModulePowerOnValueDO MF pac_WriteModulePowerOnValueDO MF pac_ReadModuleSafeValueDO MF pac_WriteModuleSafeValueDO MF PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 475 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Notes 1 The functions pac_WriteDO pac_ReadDIO pac_ReadDl pac_ReadDO pac _ReadDIO_DIBit pac_ReadDIO_DOBit pac_ReadDIBit pac ReadDOBit pac_ReadDICNT and pac_ClearDICNT which were supported in the previous SDK are used to read and write the DIO channels for pure DIO DCON modules which are defined as modules that only have DI DO or DIO channels 2 In addition to providing support for the API functions described above the PACSDK also provides the support for the Multi function API that is used to read and write the DIO channels for the Multi function DCON modules which are defined as modules that mainly act as AlO or Counters but are equipped with DIO channels Such as the 87005W I 87016W I 87082W I 7016 I 7088 etc 3 The functions mentioned above i e pac_WriteDO pac_ReadDIO etc cannot be used to access Multi function DCON modules Only the pac_xxx_MF API allows access to Multi function DCON modules 4 In both the WinPACSDK dll and the XPACSDK_CE dll PAC_IO API functions only support acc
140. dard API Manual v1 1 1 Last Revised Dec 2013 Page 418 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 9 3 pac SetBPTimer This function creates a hardware timer with the specified time out value A time out value is specified and every time a time out occurs the system posts an interrupt signal to the system and the pass the message to an application defined callback function Syntax C Bool pac SetBPTimer int type unsigned int uElapse pac TIMEROUT CALLBACK FUNC f Parameters type in Specifies the type of the timer 1 Timer 1 1 microsecond timer 2 Timer 2 10 microsecond timer Others Not applicable uElapse in Specifies the elapsed time Timer 1 A value of a timerout signal as integer from 0765535 in 1 microsecond Timer 2 A value for a timerout signal as integer from0 65535 in 10 microseconds Specifies the address of the application supplied f callback function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 419 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is zero Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return O Interrupt done y Set timer1 with 200 microsecond interval pac_SetBPTimer 1 200 TIMER PAC Standard AP
141. e please use the macro PAC REMOTE_IO 0 255 pwmBitArr out where array 0 corresponds to PWM channel O and array 1 corresponds to PWM channel 1 etc When the array is O it denotes that the PWM is inactive and 1 denotes that the PWM is active diBitArr out where array 0 corresponds to DI channel O and array 1 corresponds to DI channel 1 etc When the bit is O it denotes that the DI is inactive and 1 denotes that the DI is active PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 408 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 unsigned char pwm 32 unsigned char di 32 BOOL iRet pac GetPWMDIOStatus hPort iSlot pwm di uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 byte pwm new byte 32 byte di new byte 32 bool iRet PACNET PWM GetPWMDIOStatus hPort iSlot ref pwm ref di PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 409 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 15 pac SetPWMPulseCount This function sets the PWM step value for a specific channel Sy
142. e instructions of two fucntions i e pac WriteDO and pac_WriteDO MF are placed on the same section because of the definition of the parameters and Return Value of this pair of functions are the same The functions used to access the pure DIO DCON modules cannot be used to access Multi function DCON modules The function will return 0x14003 meaning of Uart response error if use the function to acccess Multi function DCON modules and vice versa PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 235 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PAC_IO functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx oo a A E RS YF OY O O A 5 70 5 RS PR poro o poro pro oro eine Y O O E O TS ES PE oc Yo po po oro ME O O E O Op 7 0 S pere poroso poro pro oro oyo mece poroso poro pro J gt oyo me tU poroso poro pro oro oyo pecera poroso poro poro oro oyo MEE YT eT PE RS O CO EC CO CO S pac WriteAO pac Wrtea0 MF YC o o or pero A J gt o gt pro pro J gt pere pro or pro pro oro pere poroso oro poro 05 oyo ce IH CY o o o o mean ocs lor oro loro poro poro oyo PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 236 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pa
143. e is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 360 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 33 pac_GetModuleWDTStatus This function reads the host watchdog status of a module Syntax C bool pac_GetModuleWDTStatus HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 361 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int iSlot 0 bool bStatus 0 hPort uart_Open bStatus pac GetModuleWDTStatus hPort iSlot uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open bool bStatus PACNET IO pac GetModuleWDTStatus hPort iSlot PACNET UART Close hPor
144. e to Assembly J Linker MW Embed Managed Resource File Input Force Symbol References Manifest File Delay Loaded DLLs Debugging Assembly Link Resource Syst Optimization Embedded IDL Advanced Command Line Resources XML Document Generator Browse Infornmatorn Build Events Custom Build step Luthenticode Signing E EJ ES E E Additional Dependencies Specifies additonal iteme to add to the link line ex Eemel 22 lib configuration specific RA PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 31 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 4 CH for XPAC WinPAC Series Required library files The following DLL files is needed to include to develope a XPAC WinPAC application or plug in gt PACSDXK dII gt _ PACSDK_PWM dll If 1 7K 1 87K PWM modules is used on the device How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 1 Using DII Import Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Toole Test Window Help 3 Project Crh Shift FO Web Site Shift A lN H Fik Col Project From Exiztimg Code save All Ctltshattte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 32 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select Smart Device Hew Project
145. eceives the converted Unicode string Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 445 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C char ansiString 128 This is an ansi string TCHAR uniString 128 pac_AnsiToWideString ansiString uniString MessageBox NULL uniString NULL MB OK The string This is an ansi string will show in the messagebox correctly Remarks The maximum size of the string buffer is 2 Kbytes PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 446 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 4 pac WideToAnsiString pac_WideStringToAnsi This function converts a Unicode string to an ANSI string Syntax C void pac WideToAnsiString LPCTSTR wstr LPSTR astr Parameters wstr in Points to the Unicode string to be converted astr in A pointer to a buffer location that receives the converted ANSI string Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 447 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C TCHAR uniString 128 TEXT This is a unicode string char ansiString 128 pac_WideStringToAnsi uniString ansiString printf s ansiString The
146. ed Dec 2013 Page 314 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 20 pac ReadAlAllHex This function reads all the Al values of all channels in 2 s complement mode of the Al module The function maybe causes the buffer overflow in some situation Syntax C BOOL pac ReadAlAllHex HANDLE hPort int slot int iValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iValue out The array contains the Al values that read back from the AI module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 315 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iValue 8 BOOL iRet pac_ReadAlAllHex hPort iSlot Value uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int iValue 8 BOOL iRet pac_ReadAIAllHex O iSlot iValue C f the module is 87k local IntPtr hPort hPort
147. eeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 306 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int ichannelnumberzO hPort uart_Open BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAllExt hPort iSlot fValue 8 amp ichannelnumber uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int ichannelnumber 0 float fValue 8 BOOL iRet pac_ ReadAIAllExt O iSlot fValue 8 amp ichannelnumber CH f the module is 87k local IntPtr hPort Int channelnumberzO hPort PACNET UART Open byte iSlot 1 float fValue 8 bool iRet PACNET IO ReadAIAIlExt hPort iSlot fValue 8 ref channelnumber PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 307 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 308 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpda
148. en BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue BOOL iRet pac_ReadModuleSafeValueAO hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort C If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int Channel 2 int iAO_TotalCh 8 float fValue bool iRet PACNET IO ReadModuleSafeValueAO hPort iSlot iChannel iAO_TotalCh ref fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 350 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 1 7K 1 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series have no module provided the function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 351 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 30 pac_WriteModulePowerOnValueAO This function writes the AO power on value to the AO modules Syntax C BOOL pac WriteModulePowerOnValueAO HANDLE hPort int slot int iChannel int iAO_ TotalCh float fValue Parameters hPort in The serial port HANDLE opened
149. ers hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 enStatus in bit O corresponds to PWM channel O and bit 1 corresponds to PWM channel 1 etc When the bit is 0 it denotes that the PWM output port is off and 1 denotes that the PWM output port is o Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 398 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 short Status 0x01 BOOL iRet pac_SetPWMStart hPort iSlot Status uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 short Status 0x01 bool iRet PACNET PWM SetPWMStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 399 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 10 pac_SetPWMSynChannel This function sets the PWM synchronization status for a specific channel Syntax C bool pac SetPWMSynChannel HANDLE port
150. es doesn t support SRAM PAC_MEM_EEPROM 1 Return Value The return value specifies the memory size PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 123 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C DWORD mem size mem_ size pac_GetMemorySize PAC_MEM_SRAM C uint mem_ size mem_size PACNET Memory GetMemorySize 0 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 124 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 2 pac ReadMemory This function retrieves data from the specified memory Syntax C BOOL pac_ReadMemory DWORD address LPBYTE lpBuffer DWORD dwLength int mem type PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 125 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters address in Specifies the memory address where read from EEPROM O Ox1FFF 8KB for users Ox2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system loBuffer in Receives the memory data dwLength in Number of characters to be read mem_type in Handle to a currently type memory PAC_MEM_SRAM O WP 5000 series doesn t support SRAM PAC_MEM_EEPROM 1 Return Value If the functi
151. es the PWM continuous mode 1 Enables the PWM continuous mode If the PWM continuous mode is enabled the step value for PWM will be automatically set to 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 390 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 long mode O BOOL iRet pac_SetPWMMode hPort iSlot iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong mode 0 bool iRet PACNET PWM SetPWM Mode hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 391 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 6 pac GetPWMMode This function reads the continuous mode for a specific channel Syntax C bool pac GetPWMMode HANDLE port int slot short chindex long mode Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro
152. eserved E mail service icpdas com 2 3 6 pac SDMount This function mounts the micro SD if the micro SD has been inserting to the device without mounting Syntax C bool pac SDMount LPTSTR szPartitionName Parameters szPartitionName in Name of the partition Example Part00 ReturnValue If the function succeeds the return value is TRUE icro If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 135 Examples C bool ret ret pac_SDMount TEXT Part00 C bool ret ret PACNET Memory SDMount Part00 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 136 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 7 _ pac SDOnside This function checks the Micro SD whether on side or not Syntax C bool pac SDOnside Parameters This function has no parameters ReturnValue If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 137 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C
153. ess to high profile 1 87K l 8K series modules and I 7K series modules In the PACSDK dll the processing can be modified to send DCON commands without needing to determine the module name which means that a the new PAC_IO API functions can support access to the I 87K I 8K High profile and Low profile series modules I 7K series modules I 8000 series modules units tM series modules and other OEM ODM DCON modules 5 The comparison table of pac_WriteAO pac_WriteAO_MF Functions and available modules are as following Since November 1 2012 187028CW UW S I 87022 l 87026 l 7022 l 7024 8024R l 7021 I 7021P PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 476 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 5 6 Add Misc API function for PACSDK The new PACSDK dll provides 2 miscellaneous API functions below pac_GetCurrentDirectory pac_GetCurrentDirectoryW Add the reserved memory section for XPAC series In order to reserve some memory sections of EEPROM and SRAM for the use by the system the reserved section of the pac_ReadMemory and pac_WriteMemory function must be changed Thee reserved section is same with the WinPAC SDK The definition of the items included in the reserved section is EEPROM O Ox1FFF 8KB for users 0x20000x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB wi
154. eters dll version out The version number of the PACNET dll Return Value This function does not return a value Examples CH string PacNet WinPacNet PACNET Sys GetPacNetVersion PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 85 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 19 pac_BuzzerBeep This function generates simple tones on the speaker Syntax C void pac BuzzerBeep WORD count DWORD milliseconds Parameters count in Specifies the times of beep milliseconds in Specifies the interval time in milliseconds Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 86 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_BuzzerBeep 1 100 CH PACNET Sys Buzzer BuzzerBeep 1 100 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 87 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 20 pac_GetBuzzerFreqDuty This function retrieves the frequency value and duty cycle value of the buzzer Syntax C void pac GetBuzzerFregDuty int freg int duty Parameters freq out The frequency of the sound duty out The duration of the sound Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last
155. eyExist LPCTSTR KeyName Parameters KeyName in Specific the path of registry key which you want to check whether it exists or not Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 180 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool bExist bExist pac_RegKeyExist TEXT HKEY_USERS myKey C bool bExist bExist WinPAC RegKeyExist HKEY USERS myKey PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 181 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 12 pac RegSave This function writes all the attributes of the specified open registry key into the registry Syntax C bool pac RegSave LPCTSTR KeyName Parameters KeyName in Handle to a currently open key or one of the following predefined reserved handle values HKEY_ CLASSES ROOT HKEY_CURRENT_USER HKEY_LOCAL MACHINE HKEY_USERS Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h ind
156. f you call pac_GetErrorMessage it could fail Examples C HANDLE hOpen hOpen uart_Open COM1 9600 N 8 1 C IntPtr hOpen hOpen PACNET UART Open COM1 9600 N 8 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 197 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks The uart_Open function does not open the specified COM port if the COM port has been opened Use 1 811xW 1 814xW series modules The COM port name is COME COM7 MSA1 MSB1 MSAx MSBx is an earlier old usage The new usage is COMx For example uart_Open COM6 9600 N 8 1 uart_Open MSA1 9600 N 8 1 About how to set l S11xW I 814xW series modules Please refer to the manual below w1 007 1 how to set up a communication module l 8112 8114 1 8142 1 8144 _use COM english pdf w1 007 2 how to set up a communication _module l 8112 1 8114 1 8142 1 8144 _use MSA B _ english pdf Use 1 87K series modules Only use COMO to communicate with 1 87K series modules Please refer to Sec 8 UART API PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 198 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 2 uart Close This function closes the COM port which has been opened Syntax C BOOL uart_ Close HANDLE hPort Parameters hPort in Handle to the open COM port to close Return Value If the function su
157. ge 5 E mail service icpdas com 128 131 133 135 137 139 147 149 151 153 162 164 166 168 170 172 2 5 8 pac RegGetKeylnfo 174 2 5 9 pac RegGetString 176 2 5 10 pac_RegGetValueBylndex 178 2 5 11 pac_RegKeyExist 180 2 5 12 pac_RegSave 182 2 5 13 pac_RegSetString 184 2 5 14 pac RegsSetDWORD 186 Z2 6 MARV AR I Wd GYR Cd A O ROD GN GU CN GAA OR RUBY GWR MON 188 2 6 1 uart Open 195 2 6 2 uart Close 199 2 6 3 uart_SendExt 201 2 6 4 uart Send 203 2 6 5 uart RecvExt 205 2 6 6 uart Recv 208 2 6 7 uart_SendCmdExt 210 2 6 8 uart SetTimeOut 213 2 6 9 uart_EnableCheckSum 216 2 6 10 uart_SetTerminator 218 2 6 11 uart_BinSend 220 2 6 12 uart_BinRecv 222 2 6 13 uart_BinSendCmd 224 2 6 14 uart_GetLineStatus 227 2 6 15 uart_GetDataSize 229 2 6 16 uart_SetLineStatus 230 2 72 PAC IO APR in iii 232 2 7 1 pac GetBit 243 2 7 2 pac WriteDO pac WriteDO MF 245 PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Last Revised Dec 2013 Page 6 L153 2 7 4 2 7 5 2 7 6 2 7 7 2 7 8 2 7 9 2 7 10 2 7 11 2 7 12 2 7 13 2 7 14 2 7 15 2 7 16 2 7 17 2 7 18 2 1419 2 7 20 2 7 21 2 1 22 2 7 23 2 7 24 2 7 25 2 7 20 2 7 27 2 7 28 2 7 29 PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved pac _WriteDOBit pac_ReadDO pac
158. ger than the buffer length of buf it will return FALSE Calling pac_GetLastError function will get an error code PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW Examples C BOOL ret HANDLE hOpen char buf Length hOpen uart_ Open COM1 9600 N 8 1 ret uart_RecvExt hOpen buf Length CH bool ret IntPtr hOpen byte result new byte 64 hOpen PACNET UART Open COM1 9600 N 8 1 ret PACNET UART RecvExt hOpen result 64 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 206 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change For example a Check sum is disabled This function receives five bytes ABCD 0x0D The buf will be five bytes ABCD 0x0 b Check sum is disabled This function receives four bytes ABCD The buf will be four bytes ABCD But the reurn value is O PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 207 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 6 uart Recv This function retrieves data through the COM port which have been opened This function will receive a string 0x0D Wait a character OxOD to mean the termination of a string And then if the checksum is enabled by the uart_EnableCheckSum function this function automatically check the two checksum bytes
159. gger value 07255 unit 10 microsecond 0 means disable retrigger function Return Value This function has does not return a value Examples This function has no examples Remarks The retrigger mechanism is used when the below situation occurred If an interrupt is sent but not be serviced the retrigger function will send an interrupt again This operation will continue until the interrupt has been serviced PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 95 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 26 pac GetBackplanelD This function retrieves the backplane ID Syntax C void pac GetBackplanelD LPSTR backplane version Parameters backplane_version out Retrieves the backplane ID Return Value This function has does not return a value Examples C char Backplane 32 pac _GetBackplanelD Backplane C string Backplane PACNET Backplane GetBackplanelD PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 96 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 27 pac_GetBatteryLevel This function retrieves the battery status of the backplane This function supports the following series models XPAC WinPAC PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 97 Copyright O 2013 ICP DAS Co Ltd All Rights Reserved E mail service
160. hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDl_ TotalCh 8 bool iRet PACNET IO ClearDICNT_MF hPort iSlot iChannel iDl_ TotalCh PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE _10 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 288 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 13 pac WriteAO pac WriteAO MF This function writes the AO value to the AO modules Syntax C for pac_WriteAO BOOL pac WriteAO HANDLE hPort int slot int iChannel int iAO_ TotalCh float fValue C for pac WriteAO MF BOOL pac WriteAO MF HANDLE hPort int slot int iChannel int iAO TotalCh float fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 289 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Channel in The channel that is written thee AO value to AO_ Total
161. he DI channels of the DI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 286 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_ClearDICNT Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDl_ TotalCh 8 BOOL iRet pac_ClearDICNT hPort iSlot iChannel iDl_TotalCh uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int iChannel 2 int iDl_ TotalCh 8 BOOL iRet pac_ClearDlCNT O iSlot iChannel iDI TotalCh C pac_ClearDICNT_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDl_ TotalCh 8 BOOL iRet pac_ClearDICNT_MF hPort iSlot iChannel iDl_ TotalCh uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 287 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ClearDICNT If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDI_ TotalCh 8 bool iRet PACNET IO ClearDICNT hPort iSlot iChannel iDl_ TotalCh PACNET UART Close hPort C pac_ClearDICNT_MF f the module is 87k local IntPtr
162. he version number is 1 0 0 1 or above this parameter must be 0x01000001 Return Value If the specified version number is eailer than the currently used PACSDK dll the return value is TRUE If the specified version number is later than the currently used PACSDK dll the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 62 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Added this API in the begin of your application BOOL bVersion bVersion pac_CheckSDKVersion 0x01000001 if your application should use newer than version 1 0 0 1 if bVersion MessageBox The XPacSDK dll version is wrong display some warning and close the application CH Added this API in the begin of your application bool bVersion bVersion PACNET Sys CheckSDKVersion 0x01000001 if your application should use newer than version 1 0 0 1 if bVersion MessageBox show The XPacSDK dll version is wrong display some warning and close the application y PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 63 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 7 pac ModuleExists This functions specifies whether the 10 module exist or not and is at local or remote Syntax C BOOL pac_ModuleExists HANDLE hPort BYTE slot Parameters hPort in The seri
163. hts Reserved E mail service icpdas com 2 7 11 pac_ReadDICNT pac_ReadDICNT_MF This function reads the counts of the DI channels of the DI module Syntax C for pac_ReadDICNT BOOL pac_ReadDICNT HANDLE hPort int slot int iChannel int iDl TotalCh DWORD lCounter Value C for pac_ReadDICNT_MF BOOL pac ReadDICNT MF HANDLE hPort int slot int iChannel int iDl_ TotalCh DWORD lCounter_ Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 280 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 iChannel in The channel that the counter value belongs DI_ TotalCh in Total number of the DI channels of the DI module ICounter Value out The pointer to the counter value Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 281 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_ReadDICNT Example 1 If the module is 87k local HANDLE hPort hPort
164. ial port HANDLE opened by uart_Open if the module is 87k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iChannel in The total number of DO channels of the DO modules Value in The pointer of the DO power on value to read from the DO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C pac_ReadModulePowerOnValueDO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do value BOOL ret pac ReadModulePowerOnValueDO hPort slot total channel do value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 343 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do value bool ret PACNET IO pac ReadModulePowerOnValueDO hPort slot total channel ref do_value PACNET UART Close hPort C pac_ReadModulePowerOnValueDO_MF Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do value BOOL ret pac ReadModulePowerOnValueDO MF hPort
165. icates failure To get a generic description of the error call pac GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 182 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_RegSave TEXT HKEY USERS CH bool ret ret WinPAC RegSave HKEY_USERS PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 183 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 13 pac RegSetString This function assigns the specified registry key data whose type is string Syntax C bool pac RegSetString LPCTSTR KeyName LPCTSTR assignStr DWORD dwLength Parameters KeyName in Specific the path of registry key which you want to assign data assignStr in Specific the data dwLength in Specific the size of data Return Values Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpd
166. ich must be run with XpacNet dll and XPacSDK_CE dll With the new NETCF library PACNET dll and the flowchart becomes PACSDK dll ARM PACNET dll Project Code Built as Linked with And PACSDK dll x86 The benefits of using the new SDK A program applied to WinPAC series modules and the other program applied to XPAC series modules are functionally identical because of using the same NET CF library and the API functions and error code on the library are exactly the same the source code can be shared for two programs One shared source code can be built as an executable programs and link the same NET CF library PACNET dll The only change is that links different platform native SDK PACSDK dll ARM is used on WinPAC series and PACSDK dll x86 is used for XPAC series PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 485 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Notes PACNET dll has been developed using the Net CF V2 0 environment and can be used on all XPAC and WinPAC series devices PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 486 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 5 Show a tooltip for the classes of PACNET dll When developing the programs in VS2005 VS2008 IDE typing a reference to a system class or namespace or roll over class the tooltips pop up on your cursor line
167. icpdas com ViewPAC Battery 2 Battery 1 Syntax C int pac_ GetBatteryLevel int nBattery Parameters nBattery in Specifies the index of battery 1 means first battery 2 means second battery 3 means RTC battery For XPAC_Atom series only PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 98 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value 1 means high voltage O means low voltage for XPAC series only 2 means low voltage for WinPAC series only Examples C int nBattery int index 1 nBattery pac_GetBatteryLevel index CH int nBattery int index 1 nBattery PACNET Backplane GetBatteryLevel index PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 99 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 28 pac RegistryHotPlug Beta testing This function registers the registry after turning on the hot plug Syntax C void pac_ RegistryHotPlug DWORD hWnd DWORD msglD Parameters hWnd in Specifies the handle ID Return Value This function does not return a value Examples This function has no examples PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised Dec 2013 Page 100 E mail service icpdas com 2 1 29 pac UnregistryHotPlug Beta testing This f
168. in The total number of DI channels of the DIO module DO_ TotalCh in The total number of DO channels of the DIO module IDI Value out The pointer to the value of DI read back IDO_ Value out The pointers to the value of DO read back Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 264 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_ReadDIO Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI_ TotalCh 8 int iDO TotalCh 8 DWORD IDI Value DWORD IDO Value BOOL Ret pac_ReadDIO hPort iSlot iDI TotalCh DO TotalCh amp IDI Value amp IDO Value uart_Close hPort Example 2 1f the module is 8k local BYTE iSlot 1 int iDI_ TotalCh 8 int iDO_ TotalCh 8 DWORD IDI Value DWORD IDO Value BOOL iRet pac_ReadDIO O iSlot iDl_ TotalCh iDO_TotalCh amp IDI_ Value amp IDO Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 265 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac ReadDlO MF Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI_ TotalCh 8 int iDO_ TotalCh 8 DWORD IDI_ Value DWORD IDO Value BOOL iRet p
169. inCE 6 0 Based Standard XPAC with 3 1 0 slots XP 8741 Atom CE6 WinCE 6 0 Based Standard XPAC with 7 1 0 slots WinPAC family for Arm platform series WP 8000 Series WP 5000 Series VP 2000 Series PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 12 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Related Information For additional information about your PAC that can be obtained from CD or by downloading the latest version from ICP DAS web site XPAC family for x86 series XP 8000 CE Series CD XP 8000 CE6 Document http www icpdas com products PAC xpac download xpac_ce6 download documents ht m XP 8000 Atom CE6 Series CD XPAC ATOM CE6 Document http www icpdas com products PAC xpac download xpac atom ce6 download docum ents htm WinPAC family For WP 8000 series CD Napdos wp 8x4x_ce50 document http www icpdas com products PAC winpac download winpac 8000 download docum ents htm For WP 5000 series CD Napdos wp 5000_ce50 Document http www icpdas com products PAC winpac download winpac 5000 download docum ents htm For VP 2000 series CD Napdos vp 2000_ce50 Document http www icpdas com products PAC viewpac download viewpac download document s htm PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 13 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com How to contact us For support for this or any
170. inPacSDK dll Code Built as Linked with Project B C EXE x86 XPacSDK_CE dll Code Even if Project A applied to WinPAC series modules and Project B applied to XPAC series modules are functionally identical The source code using the previous SDK cannot be exactly the same because of using the different header file and the few function names and error code defined in the previous SDK are different So Project A and Project B are regarded as separate programs cannot share the source code The results of the above are Project A is built as an ARM based executable program and it must be run with WinPacSDK dll Project B is built as an x86 based executable program and it must be run with XPacSDK_CE dll The flowchart for a C program that is now calling the new SDK PACSDK dll is as follows C EXE ARM PACSDK dll ARM Project Built as Linked with Code C EXE x86 PACSDK dll x86 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 479 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com The benefits of using the new SDK A program applied to WinPAC series modules and the other program applied to XPAC series modules are functionally identical because using the same header file and the API functions and error code on the library are exactly the same the source code can be shared for two programs The Project with the shared source code can be b
171. ing the registry functions PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 157 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the registry functions XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx Y Y Functions Models XP 8000 CE6 i lt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 158 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Registry Functions The following functions are used to retrieve or set the registry PACSDK Functions PACNET Functions Description PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 159 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 1 pac_RegCountKey This function retrieves the specified registry key which has how many sub keys Syntax C DWORD pac_RegCountKey LPCTSTR KeyName Parameters KeyName in Specifies the path of registry key which you want to count Return Value Return the number of subkeys contained by the specified key PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 160 Examples C DWORD i i pac_RegCountKey TEXT HKEY_USERS myKey C uint i i Wi
172. interruptEvent BYTE slot HANDLE hEvent Parameters slot in Specifies the index of slot to retrieve the event handle hEvent in Event to be signaled Return Value This function has does not return a value Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 115 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 8 pac SetTriggerType This function assigns the pulse trigger type for separate slot Syntax C void pac SetTriggerType BYTE slot int iType Parameters iType in Specifies the pulse trigger type O Rising edge trigger default 1 Level trigger 2 Falling edge trigger Return Value This function has does not return a value Examples This function has no examples Remarks For XP 8000 series only support level trigger type PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 116 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 9 pac_GetSlotinterruptiD This function retrieves the ID of the slot interrupt Syntax C DWORD pac_GetsSlotlnterruptlD BYTE Slot Parameters slot in Specifies the slot Return Value If the function succeeds the return value is the ID of the slot interrupt If the function fails the return value is FALSE To get extended error information call pac_GetLastError Examples This fun
173. ion clears the counter values of the counter frequency modules Syntax C BOOL pac _ClearCNT HANDLE hPort int slot int iChannel Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that clears the counter value back from the counter frequency modules Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 321 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int Channel 0 BOOL iRet pac_ClearCNT hPort iSlot iChannel uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int Channel 0 BOOL iRet pac_ClearCNT O iSlot iChannel CH If themodule is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int Channel 0 bool iRet PACNET IO ClearCNT hPort iSlot iChannel PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local
174. isterSlotlnterrupt This function registers the slot interrupt service route after turning on the slot interrupt Syntax C BOOL pac RegisterSlotlnterrupt BYTE slot PAC CALLBACK FUNC f Parameters slot in Specifies the index of slot A call back function Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 105 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something return true if return true SDK will do pac_InterruptDone automatically else users should do pac InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or flase needn t add pac InterruptDone and it will work correctly void ClntrDlg OnButton1 pac_RegisterSlotinterrupt slot slot callback_ proc pac_EnableSlotinterrupt slot true enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false disable slot interrupt pac_UnregisterSlotinterrupt slot unregister slot interrupt y Remarks for XPAC series only Default trigger type is level trigger For XP 8000 series only support level trigger type PAC Standard A
175. it PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 145 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com A unit is about 0 5 seconds 1 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds for WinPAC series only The hardware watchdog second Parameter is a value which between 1 31 unit A unit is about 200 milliseconds 1 means the shortest timeout otherwise 31 is longest and it takes about 6 2 seconds In addition the watchdog time cannot be zero PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 146 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 2 _ pac DisableWatchDog This function stops a watchdog operation Syntax C void pac DisableWatchDog int wdt Parameters wat in Specifies the Watchdog type PAC WDT HW O PAC WDT OS 1 Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 147 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac _DisableWatchDog PAC_WDT_OS CH PACNET Sys WDT DisableWatchDog 1 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 148 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 4 3 pac RefreshWatchDog This function refreshes the watchdog Syntax
176. its own definition and corresponding communication ports and slots whose parameters are defined as below As a result apply the corresponding slot and COM port number on the API functions in writing program XP 8341 CE6 XP 8341 Atom CE6 WP 84x1 WP 5141 XP 8041 CE6 XP 8141 Atom CE6 WP 81x1 VP 2xW1 XP 8741 CE6 XP 8741 Atom CE6 WP 88x1 WP 5141 OD COM1 RS 232 Backplane Backplane Backplane RS 232 RS 232 RS 232 Backplane It s RS232 interface used for accessing the 1 87K module only PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 498 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 1 XP 8041 CE6 COM4 COM5 RS 232 RS 485 EE RS 232 COM2 COM RS 232 RS 232 COM m RS 485 L v PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 499 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 2 XP 8341 CE6 XP 8741 CE6 COM4 T E coms RS 232 RS 485 9 mL RS 232 lO COM2 RS 232 XP 8341 CE6 COM Slot 1 3 XP 8741 CE6 COM1 Slot 1 7 COM mr RS 485 L vo PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 500 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com F 3 XP 8141 Atom CE6 COM4 7 COM5 RS 232 RS 485 8 WW RS 232 COM2 RS 232 COM Slot 1 COM mit RS 485 0 PAC Standard API Manual v1 1 1 L
177. l to be added to the current project OWin32 WCE MIPSIL FP y PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 27 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 4 On the configuration toolbar select the Win32 WCE ARMV4 Release H test Microsoft eMbedded Visual C File Edt View Insert Project Bud Tools Window Help 4 SU Alo G WBS Read wm Ionas TAW gional nembers e nembers Greate New Class Le ki PAC270 Win32 WCE ARMVYAI Debug PAC270 Device ey be Y El Step 5 Include PACSDK h Hinclude PACSDK h include stdafx h include SUKI nformation h Finclude slEInformationllz h include PACE H Step 6 Include PACSDK lib In the right pane type the PACSDK lib in the textbox Project Settings settings For General Debug C Win32 WCE ARMVAI Helease W gt Category General Output file name JARMY4IRel systeminfa exe Mules IPACSDK lib 3 Generate debug Info Ignore all default llbrarles Generate mapfile Project Options nologo foace 10001 0000 fetack OT 0000 0x1 000 Jentry w WinMainCRT5tartup incremenial n o fpdb ARMY 4lRel systeminto pdb cancel PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 28 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 3 C C MFC based on Visual Studio f
178. lCh amp fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 299 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAl_ TotalCh 8 float fValue bool iRet PACNET IO ReadAl hPort iSlot iChannel iAl_ TotalCh ref fValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 300 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 16 pac ReadAlHex This function reads the 2 s complement mode AI value of the AI module Syntax C BOOL pac _ReadAlHex HANDLE hPort int slot int iChannel int iAl_ TotalCh int iValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 301 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote ple
179. le PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 382 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 float fValue 1 23 BOOL iRet pac_SetPWMDuty hPort iSlot iChannel fValue uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 float fValue 1 23 bool iRet PACNET PWM SetPWMDuty hPort iSlot iChannel fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 383 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 2 pac GetPWMDuty This function reads the duty cycle value for a specific channel Syntax C bool pac SetPWMDuty HANDLE port int slot short chindex float duty Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Get the duty cycle value from the channel duty out The duty cycle value to read to the PWM module
180. library files will are copied to the default location on PC C Program Files Windows CE Tools wce500 PAC270 Include Armv4i C Program Files Windows CE Tools wce500 PAC270 Lib ARMVAI After the package of XPAC platform SDK has installed to PC the PACSDK library files will are copied to the default location on PC C Program Files Windows CE Tools wce600 XPacSDK_CE Include X86 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 20 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com To Update the XPACSDK WinPACSDK to PACSDK The documents w6 10 How to update to PACSDK library_from_WinPacSDK_library_en pdf and w6 10 How _ to update to PACSDK library from WinPacSDK library_tc pdf describe how update PACSDK library to replace WinPACSDK library on user s program It located at http ftp icodas com pub cd winpac napdos wp 8x4x ce50 document faq sdk The documents X6 10 How to update to PACSDK_library_from_XPacSDK_library_en pdf and X6 10 How to update to PACSDK library from XPacSDK library _tc pdf describe how update PACSDK library to replace XPacSDK library on user s program It located at http ftp icpdas com pub cd xp 8000 ce6 document fag sdk or http ftp icodas com pub cd xpac atom ce6 document faq sdk PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 21 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 3 Setting up the Development
181. ll O pac_SyncPWMStart Y pacsetpwoPulsecount Y YF YT eT o O pac Setpwmputsecount Y YF LL ll TO ii lt lt lt lt lt lt lt e HM FFF FFF lt lt l H l H FFF PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 467 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Backplane Functions VP 25Wx VP 23Wx Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx pac_GetBPTimerTimeTick_ms pac_GetBPTimerTimeTick_us pac_SetBPTimerOut pac_SetBPTimerinterruptPriority pac_KilBPTimer e poro pro vyY n no Y oro pro vol o on pac setepTimer YY Y o oro o Y pro r vro o gt n no e pro n yo yo N Error Handling Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_GetLast rror Y Y pac_SetLastError pac_GetErrorMessage pac_ClearLastError PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 468 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Misc Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx VH 25Wx AnsiString WideString pac_AnsiToWidestring pac_WideToAnsiString pac_ Y Y Y Y Y Y Y Y Y WideStringToAnsi pac_DoEvent pac_DoEvents pac_GetCurrentDirect
182. located at CD root XP 8000 CE6 SDK XPacNET in the companion CD ftp ftp icodas com pub cd xp 8000 ce6 sdk xpacnet Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Tools Test Window Help Project tr shitty Web site shit t t NT File Ctd N Project From Existing Code save All Ciltshaittte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 36 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select Smart Device New Project Project types E Visual C e Windows Web mad Device Office i Database Reporting oo ele Tit component ele _SenptTask i Test o WCF e Workflow Fj Other Languages H Other Project Types H Test Projecte Templates My Templates ra mart Device Project EE Visual Studio installed templates search Online Templates project for Smart Device applications Choose target platfonn Framework version and template in the next dialog box Name Location solution Mame Add New Smart Device Project SmartDeviceProgectl Target platform smeatDeviceProjectl martDeviceProjectl Create directory for solution MET Compact Framework version WET Compact Framework Version 3 5 w Templates Download additonal emulator images and smart device DES PAC Standard API Manual v1 1 1 Copyright 2013 ICP DAS Co Ltd All
183. lot int iDO_TotalCh DWORD IDO Value How to use in your NET project e Added this line in your project using System Runtime InteropServices e Declare this function as following Dill mport PACSDK dll EntryPoint pac WriteDO public extern static bool pac _WriteDO IntPtr hPort int slot int iDO_TotalCh uint IDO_ Value e Then you can use this function pac_WriteDO in your NET project Code Snippet using System Windows Forms using System Runtime InteropServices namespace WindowsFormsApplication2 public partial class Form1 Form Dill mport PACSDK dll EntryPoint pac _WriteDO public extern static bool pac_WriteDO IntPtr hPort int slot int iDO_TotalCh uint IDO Value public Form1 InitializeComponent PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 34 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com y private void button1_Click object sender EventArgs e pac_WriteDO IntPtr O 1 16 Oxff j I j PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 35 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 Using PACNET dll PACNET dll is a net Compact framework SDK and PACNET dll isn t used for C program but also used for VB net program gt PACNET diI the execution file should be put in the same directory of the PACNET dll The latest version of this library is
184. message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 164 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_RegCreateKey TEXT HKEY_USERS myKey C bool ret ret WinPAC RegCreateKey HKEY_USERS myKey PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 165 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 4 pac_RegDeleteKey This function deletes a named subkey from the specified registry key Syntax C bool pac RegDeleteKey LPCTSTR KeyName Parameters KeyName in Specifics the path of registry key which you want to delete Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 166 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C bool ret ret pac_RegDeleteKey TEXT HKEY_USERS myKey C bool ret ret WinPAC RegDeleteKey HKEY_USERS myKey Remarks
185. modem line Syntax C DWORD uart_SetLineStatus HANDLE hPort int pin int mode Parameters hPort in Handle to the open COM port pin in A variable specifies state of a pin of the COM port This parameter can be following values Hdefine DTR 1 Hdefine RTS 2 Hdefine DTR RTS 3 mode in O Disable Set the pin signal is OFF 1 Enable Set the pin signal is ON PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 230 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is nonzero If the function fails the return value is zero To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure If error code getting from pac_GetLastError is PAC_ERR UART GET COMM _ STATUS ERROR call the GetLastError function to obtain the last error ocde of Windows API Examples C HANDLE hPort uart_Open COM5 9600 N 8 1 DTR pin on COM5 of XPAC HANDLE hPort uart_Open COM4 9600 N 8 1 DTR pin on COM4 of WinPAC uart_SetLineStatus hPort 1 1 set DTR to ON uart_Close hPort C IntPtr hPort PACNET UART Open COM5 9600 N 8 1 DTR pin on COM5 of XPAC ntPtr hPort PACNET UART Open COM4 9600 N 8 1 DTR pin on COM4 of WinPAC PACNET UART SetLineStatus hPort 1 1 _ set DTR to ON PACNET UART Close hPort PAC Standard API Manual v1
186. mount O O O O UCH A WP 5xxx only supports the memory type 1 EEPROM not type O SRAM PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 460 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Watchdog Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 461 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Registry Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_RegCountKey pac_RegCountValue pac_RegCreateKey pac _RegDeleteKey pac_RegDeleteValue Y pac_RegGetDWORD YY YT yn y Y pac_RegGetKeyBylndex pac_RegGetKeylnfo ii lt i pac_RegGetString pac_RegGetValueBylndex pac_RegKeyExist pac_RegSave pac_RegSetString pac _RegSetDWORD H FEE Le 4 FEN FEN t t t f PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 462 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com UART Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx watese Y o Y YY Yo Yo oc Y lt lt lt lt lt lt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 463 Copyright 2013 ICP DAS
187. n the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 304 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 17 pac ReadAlAllExt This function reads all the AI values of all channels in engineering mode of the AI module This function replaces pac_ReadAlAll Syntax C BOOL pac_ReadAIAll HANDLE hPort int slot float fValue DWORD Buff Len DWORD Channel PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 305 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE _10 0 255 fValue out The array contains the AI values that read back from the AI module Buff_Len in A pointer to a variable that specifies the size of the buffer pointed to by the fvalue Channel out The pointer to a variable that specifies the total available channel numberer of Al module This channel number is only valid if the return value is TRUE Return Value If the function succ
188. nPAC RegCountKey HKEY_USERS myKey PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 161 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 2 pac_RegCountValue This function retrieves the specified registry key which has how many values Syntax C DWORD pac_RegCountValue LPCTSTR KeyName Parameters KeyName in Specific the path of registry key which you want to count Return Value Return the number of values associated with the key PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 162 Examples C DWORD i i pac_RegCountValue TEXT HKEY_USERS myKey C uint i i WinPAC RegCountValue HKEY_USERS myKey PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 163 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 5 3 pac RegCreateKey This function creates the specified registry key Syntax C bool pac RegCreateKey LPCTSTR KeyName Parameters KeyName in Specific the path of registry key which you want to create Return Value Return true if success otherwise false To get an error code call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The
189. nRecv This function is applied to receive the fix length response The length of the receiving response is controlled by the Parameter in_Len The difference between this function and uart_Recv is that uart_BinRecv terminates the receiving process by the string length in_Len instead of the character CR Carry return Therefore this function receives the response string data with or without null character under the consideration of receiving length Besides because of this function without any error checking mechanism checksum CRC LRC etc users have to remove the error checking information from the raw data by themselves if communication checking system is used Syntax C bool uart BinRecv HANDLE hPort LPSTR buf DWORD in_Len Parameters hPort in Handle to the open COM port buf out A pointer to a buffer that receives the data in_Len in The length of result string PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 222 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is 1 If the function fails the return value is O Examples C bool ret HANDLE hPort char buf 2 hPort uart_ Open COM4 9600 N 8 1 ret uart_BinSend hPort AB 2 ret uart_BinRecv hPort buf 2 uart_Close hPort CH bool ret IntPtr hPort byte buf new byte 100 hPort
190. nd Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 ft in A call back function Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 373 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 int CALLBACK slot_callback_proc do something return true int iSlot O pac InitModuleWDTinterrupt iSlot slot_callback_proc C PACNET CALLBACK_FUNC slot_callback_ proc global int slot _callback_proc do something return 0 int Slot 0 PACNET IO InitModuleWDTInterrupt iSlot slot_callback proc Remarks I 8K series modules provided with Power ON or Safe Value function can support this API function At present only 8041RW has this feature in all I 8K modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 374 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 39 pac GetModuleWDTinterruptStatus This function reads interrupt status of a module watchdog Syntax C short pac GetModuleWDTinterruptStatus int slot Parameters slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 Return
191. nstallation package 1 Get the latest version of the installation package of WinPAC XPAC platform SDK which supports PACSDK library XPAC CE6 platform SDK The latest version of the installation package from FTP site isted as following FTP http ftp icodas com pub cd xp 8000 ce6 sdk platformsdk http ftp icodas com pub cd xpac atom ce6 sdk platformsdk File name xpacsdk_ce_n n n_VSXXXX Msi n n n platform sdk version number xxxx 2005 indicates VS2005 2008 indicates VS2008 Tips amp Warnings A The version number of SDK installation package provided the PACSDK library must be later than or equal to 1 4 0 such as XPacSDK_CE_1 4 0 VS2008 msi or XPacSDK_CE_ 1 4 0 VS2005 msi WinPAC platform SDK The latest version of the installation package from FTP site listed as following FTP http ftp icpdas com pub cd winpac napdos wp 8x4x ce50 sdk File name pac270 sdk yyyymmdd msi yyyymmdd platform sdk released date Tips amp Warnings A The released date of SDK installation package that provides the PACSDK library must be later than or equal to 2012 10 15 such as PAC270_SDK_20121015 msi PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 19 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 Run the installation packge msi on PC and follow the prompts until the installation is complete After the package of WinPAC platform SDK has installed to PC the PACSDK
192. nt total channel 8 DWORD do _value 4 _ turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO hPort 1 total channel do_value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 339 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_WriteModulePowerOnValueDO Example 1 1f the module is remote IntPtr hPort PACNET UART Open COM41 9600 N 8 1 int total channel 8 uintdo_value 4 turnonthe channel two bool ret PACNET IO pac WriteModulePowerOnValueDO hPort PACNET IO REMOTE_IO 1 total channel do_value PACNET UART Close hPort Example 2 If the module is 87k local IntPtr hPort PACNET UART Open int total channel 8 uint do value 4 turn on the channel two bool ret PACNET IO pac WriteModulePowerOnValueDO hPort 1 total channel do_value PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 340 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac WriteModulePowerOnValueDO MF Example 1 1f the module is remote IntPtr hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uintdo_value 4 turnonthe channel two bool ret PACNET IO pac WriteModulePowerOnValueDO MF hPort PACNET IO REMOTE_IO 1 total channel do_value PACNET UART Close hPort Ex
193. ntax C bool pac SetPWMPulseCount HANDLE port int slot short chindex long cnt Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel cnt in The PWM steps 0x0001 to OxFFFF When set to more than 1 step the PWM continuous mode will be automatically set to disabled PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 410 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 long Icnt 1 BOOL iRet pac_SetPWMPulseCount hPort iSlot iChannel Icnt uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 long Icnt 1 bool iRet PACNET PWM SetPWMPulseCount hPort iSlot iChannel Icnt PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 411 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 16 pac_Get
194. o receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 iChannel in The channel that is written thee AO value to iAO_ TotalCh in The total number of the AO channels of the AO module float fValue in The AO value to write to the AO module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 346 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue 5 BOOL iRet pac_WriteModuleSafeValueAO hPort iSlot iChannel iAO TotalCh fValue uart_Close hPort C If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int Channel 2 int iAO_TotalCh 8 float fValue 5 bool iRet PACNET IO WriteModuleSafeValueAO hPort iSlot iChannel iAO TotalCh fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 347 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Paramete
195. odifications and updates for more details The suite of the I O WDT PowerOn Safe Value API functions for Multi function modules is also placed in PACNET PAC IO class Add Misc API function for PACSDK Refer to Add Misc API function for PACSDK reference of PACSDK dll modifications and updates for more details The suite of misc API function is placed in PACNET MISC class PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 482 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 3 Enumerate the error codes Add a function to enumerate all the error codes for PACSDK The code snippet is as follows The code is applicable to every C VB demo file uint ec PACNET ErrHandling pac_GetLastError MessageBox Show PACNET ErrCode ec ToString nError Code Ox ec ToString X The sample code is used to show the error code number and its enumerated definition If the last error code 0x10001 is happened on the user s program The message box with PAC_ERR_ UNKNOWN Error Code 0x10001 caption will be shown PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 483 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 4 Using the new SDK PACNET in a C or VB net program To use the new PACNET in a C or VB net program some code needs to be changes in the program In a CH program Modify the code for using XPAC series devi
196. oduleWDTInterrupt pac_SetModuleWDTInterruptStatus pac_GetModuleWDTInterruptStatus pac_ReadModuleSafeValueDO pac_WriteModuleSafeValueDO pac_ReadModuleSafeValueAO pac_WriteModuleSafeValueAO pac_ReadModulePowerOnValueDO pac_WriteModulePowerOnValueDO pac_ReadModulePowerOnValueAO pac_WriteModulePowerOnValueAO PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 473 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Notes 1 The each of API function is used for the DCON module which is provided with Power ON or Safe value function 2 1 7K l 87K series modules provided with Power ON or Safe Value function can support the API functions above I 8K series module provided the functions is only I 8041RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 474 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 4 Add 1 0 accessing API functions for the Multi function modules The new PACSDK dll provides the support of 1 0 accessing functions including Write Read DIO AIO Read DI counter and 1 0 WDT Power On and Safe value function for the Multi function DCON modules Refer to Note 2 regarding of the definition of Multi function modules These functions aren t supported for the previous SDK WinPAC dll and XPACSDK_CE dll pac_WriteAO_MF Note 5 pac_WriteModulePowerOnValueAO MF pac_WriteModuleSafeValueAO MF pac_WriteDO MF pac Rea
197. on fails the return value is FALSE To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 112 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks Default trigger type is level trigger For XP 8000 series only support level trigger type If you want to get the registered event handle please call this API pac_GetSlotinterruptEvent PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 113 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 6 pac _GetSlotinterruptEvent This function retrieves the slot event handle which registered by pac_Interruptinitialize Syntax C HANDLE pac_ GetSlotinterruptEvent BYTE slot Parameters slot in Specifies the index of slot to retrieve the event handle Return Value If the function succeeds this program handles the event object If the function fails the return value is NULL To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 114 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 7 pac SetSlotinterruptEvent This function allows a device driver to assign the slot event handle Syntax C void pac SetSlot
198. on succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError A nonzero error code defined in PACERROR h indicates failure To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 126 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C define LENGTH 2 bool ret DWORD address O BYTE Buffer LENGTH ret pac_ReadMemory address Buffer LENGTH PAC_MEM_SRAM C bool ret uint address 0 byte Buffer new byte 2 ret PACNET Memory ReadMemory address Buffer 2 O Remarks If an older program is coded to write data to the 0x2000 Ox3FFF address of the EEPROM or to the last segment of the SRAM using the SDK version 2 0 1 0 or earlier the program may fail to write the data to the EEPROM or the SRAM using the PACSDK dll or PACNET dll There are two ways to fix the problem 1 Modify the program so that the data is writhen to the OTOx1FFF address of the EEPROM or the O Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 127 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 3 pa
199. or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 1 7K 1 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series have no module provided the function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 354 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 31 pac ReadModulePowerOnValueAO This function reads the AO power on value of the AO module Syntax C BOOL pac _ReadModulePowerOnValueAO HANDLE hPort int slot int iChannel int iAO_ TotalCh float fValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iChannel in Read the AO value from the channel iAO_ TotalCh in The total number of the AO channels of the AO module float fValue in The pointer to the AO power on value that is read back from the AO module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 355 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fail
200. or WinPAC Series Required header and library files The following list lists the libraries header files or DLL files you will need to include developing a WinPAC application or plug in gt PACSDK h gt PACSDK lib If 1 7K 1 87K PWM modules is used on XPAC series device you need to include or plug in the files below gt PACSDK_PWM h gt PACSDK PWM lib How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Toole Test Window Help Project tr hitt Web site shaft lt File Ctd N Project From Existing Code eave All Ctltshittte Recent Files Recent Projects Exit PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 29 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Step 2 Select Smart Device Hew Project Project types Templates NET Framework 3 5 ke El E Visual C Visual Studio installed templates G Other Languages Visual Basic qu ATL smart Device Project oy MFC Smart Device ActiveX Control Ua aa MFC Smart Device Applicaton alt MEC Smart Device DLL gal Win 22 Smart Device Project My Templates aeach Online Templates Other Project Types a Test Projects A n application for Windows Mobile and other Windows CE based devices that uses the Microsoft Foundation Class Library Name Location Soon Nene
201. ort HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 chlndex in Set the duty cycle value from the channel config out O Disables the hardware trigger 1 Enables the trigger start 2 Enables the trigger stop PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 396 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode BOOL iRet pac_GetPWMDITriggerConfig hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode bool iRet PACNET PWM GetPWMDITriggerConfig hPort iSlot iChannel ref mode PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 397 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 9 pac SetPWMStart This function sets the status of the PWM output port Syntax C bool pac SetPWMStart HANDLE port int slot short enStatus Paramet
202. ory pac_GetCurrentDirectoryW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 469 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix C What s New in PACSDK PACSDK is the next version of XPACSDK and WinPACSDK It builds on the features of XPACSDK and WinPACSDK library by providing the following PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 470 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C 1 PACSDK dll modifications and updates The new PACSDK dll provides support for two platforms one being designed for the WinPAC series ARM platforms and the other for the XPAC series x86 platforms However there are a number of modifications and updates that are included in the new PACSDK which are listed below Note Compared to the previous WinPAC XPAC SDK these modification and updates need to be made to the previously implemented WinPAC XPAC programs so that it will work with the new SDK 1 pac_EnableLED The original pac_EnableLED bool bFlag function can be used only for the WinPAC series in the previous SDK and the original pac_EnableLED int pin bool bFlag function can be used only for the XPAC series in the previous SDK Conseguently this API function cannot be integrated to the PACSDK dll because of the conflicting parameters As a result the function in PACSDK dll has been changed to pac_EnableLED bool
203. pyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C HANDLE hPort char result 32 hPort uart Open Open COMO data format 115200 N 8 1 uart_SetTerminator hPort r pac ChangeSlot 0 A I 87K module is in slotO uart SendCmd hPort SOOM result SOOM ask the device name DCON uart_Close hPort C byte result new byte 32 IntPtr hPort PACNET UART Open Open COMO data format 115200 N 8 1 PACNET UART SetTerminator hPort WinPAC AnsiString r PACNET Sys ChangeSlot 0 A I 87K module is in slotO PACNET UART SendCmd hPort WinPAC AnsiString SOOM result SOOM ask the device name DCON string str PACNET MISC WideString result PACNET UART Close hPort Remarks This function relates to uart_Send uart_Recv uart_SendCmd PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 219 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 11 uart_BinSend Send out the command string by fix length which is controlled by the Parameter in Len The difference between this function and uart_Send is that uart_BinSend terminates the sending process by the string length in_Len instead of the character CR Carry return Therefore this function sends out command string with or without null character under the consideration of the command length Besides because of thi
204. r Codes ccscsssssscscsccccccscsccccccscsccccccscsccccccscsscees 455 Appendix B API COMpaLiSON cccsccccscscccsccscsccccccsceccccccscsccccccscsccecccsceseees 457 Appendix C What s New in PACSDK cscscsscsssccscecsscsccccsccccsceccscsseccscesens 470 C 1 PACSDK dll modifications and UPAAateS ccceccccecsceccccccsceccccecsceccccecscececcecsces 471 1 pac EnableLED 471 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 9 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 Add Registry API for XPAC series 472 3 Add I O WDT PowerOn Safe Value API for pure DIO modules 473 4 Add 1 0 accessing API functions for the Multi function modules 475 5 Add Misc API function for PACSDK 477 6 Add the reserved memory section for XPAC series 477 7 Using the new SDK PACSDK in a C program 478 C 2 PACNET SDK modifications and UPCates cscsceccecscscsceccccscsceccccscscescccecscecess 481 1 API function classification 481 2 API functions modification 482 3 Enumerate the error codes 483 4 Using the new SDK PACNET in a C or VB net program 484 5 Show a tooltip for the classes of PACNET dll 487 C 3 Error code modifications and UPCAtES ceececscsccccccscsccccccscsceccccecsceseececscesecs 488 dE For WinPAC series 488 2 For XPAC series 490 Appendix D Using the Multi function DCON module ccccscsscssesceeces 492 1 On WinPAC devices 4
205. r need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 1 7K 1 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series have no module provided the function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 348 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 29 pac ReadModuleSafeValueAO This function reads the AO safe value of the AO module Syntax C BOOL pac _ReadModuleSafeValueAO HANDLE hPort int slot int iChannel intiAO TotalCh float fValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AO value from the channel IAO_ TotalCh in The total number of the AO channels of the AO module float fValue in The pointer to the AO safe value that is read back from the AO module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 349 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Op
206. rd compatible is running Otherwise return the index of COM port in the normal mode Remarks The function is only applied to the WP 8000 sereis and it is used for back compatible with old PAC controller WinCon series Examples eVc int currentCOM _ current com port int normalCOM com port index in normal mode currentCOM pac_GetComMapping normalCOM If the device is running on normal mode then the return value currentCOM eauals normalCOM ex normalCOM 0 after this API the currentCOM 0 too Otherwise if the device is running on backward compatible mode then the return value currentCOM is backward compatible mapping index ex normalCOM O after this API the currentCOM 1 C int currentCOM int normalCOM currentCOM PACNET Sys GetComMapping normalCOM PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 81 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 17 pac_GetModuleType This function retrieves the type of 1 0 modules which plugged into the WinPAC XPAC series devices Syntax C int pac_GetModuleType int slot Parameters slot in Specifies the slot number where the I O module is plugged into PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 82 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value For WinPAC 8000
207. retrieved value is null means the function executes failure or the device is not valid product PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 57 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 4 pac_GetSDKVersion This function retrieves the version number of the current PACSDK dll Syntax C void pac_GetSDKVersion LPSTR sdk_ version Parameters sdk_version out The version number of the PACSDK Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 58 Examples C char SDK 32 pac GetSDKVersion SDK C string PacSDK string PacNET PacSDK PACNET Sys GetPacSDKVersion retrieving XPacSDK version PacNET PACNET Sys GetPacNetVersion retrieving XPacNET version n net ths API is different with VC And there are two API pac GetXPacSDKVersion and pac GetXPacNetVersion PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 59 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 5 pac ChangeSlot This function handles the slot from one to another Syntax C void pac_ChangeSlot BYTE slotNo Parameters slotNo in Specifies the slot number which the 87K module plug in Return Value This function does not
208. return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Page 60 Examples C BYTE slot HANDLE hPort BOOL ret char buf Length hPort uart_Open pac _ChangeSlot slot Change to the slot which the 87k modules plug in ret uart SendCmd hPort SOOM buf SOOM ask the device name C BYTE slot IntPtr hPort bool ret string buf hPort PACNET UART Open PACNET MISC AnsiString PACNET Sys ChangeSlot slot Change to the slot which the 87k modules plug in ret PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM buf Remarks When you use uart API and the lO modules located as slots You have to call pac_ChangeSlot to change the slot Besides other low level operations may use pac_ChangeSlot to change the slot If you just use PAC_IO APIs you needn t care about this PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 61 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 6 pac CheckSDKVersion This function is used to compare the version number of the currently used PACSDK dll with the specified versionon number This function does not support all versions of XPACSDK and WinPACSDK Syntax C BOOL pac CheckSDKVersion DWORD version Parameters version in The version number of the PACSDK If t
209. riting EEPROM or SRAM or mounting ummounting MicroSD PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 120 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the memory access functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 5xxx VP 25Wx VP 23Wx ac_GetMemorySize til er Y Y Y Y Y YA Y Y ac_GetMemorySize pac_ReadMemory Y props oY pacwritememory Y a o ooo pac EnableeePRoM Y 1 Y Yo po Yo ro mc Bs Yo Yoo o Yo pr Yo jeacsomount Yo Yoo o Yo pro Yo mem ll Y o Y Yo or feacsounmount e poro o oyo po yoyo Yo A WP 5xxx only supports the memory type 1 EEPROM not type O SRAM PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 121 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Memory Access Functions The following functions are used to retrieve or set the memory PACSDK Functions PACNET Functions Description PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 122 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 3 1 pac GetMemorySize This function retrieves the size of the specified memory Syntax C DWORD pac_GetMemorySize int mem_type Parameters mem_type in Handle to a currently type memory PAC_MEM_SRAM O WP 5000 seri
210. s 300 uart_SetTimeOut hOpen mes CTO TIMEOUT ALL uart_Close hOpen CH IntPtr hOpen uint msc hOpen PACNET UART Open COM1 9600 N 8 1 mes 300 PACNET UART SetTimeOut hOpen msc O PACNET UART Close hOpen PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 214 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks CTO_READ_TOTAL_TIMEOUT A constant used to calculate the total time out period for read operations in milliseconds A value of zero for the CTO READ TOTAL TIMEOUT indicates that total time outs are not used for read operations CTO_WRITE_TOTAL_TIMEOUT A constant used to calculate the total time out period for write operations in milliseconds A value of zero for the CTO WRITE TOTAL TIMEOUT indicates that total time outs are not used for write operations CTO_READ_RETRY_TIMEOUT A constant used to calculate the time out period for read operations in system tick count CTO_TIMEOUT_ALL A constant used to calculate the total time out period for write and read operations in milliseconds A value of zero for the CTO_TIMEOUT_ALL indicates that total time outs are not used for write and read operations PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 215 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 9 _ uart EnableCheckSum This function turns on the check sum or not Add two checks
211. s the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO TotalCh 8 float fValue BOOL iRet pac_ReadModulePowerOnValueAO hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue bool iRet PACNET IO ReadModulePowerOnValueAO hPort iSlot iChannel iAO_TotalCh ref fValue PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 356 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 1 7K 1 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series have no module provided the function PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 357 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 32 pac_GetModuleLastOutputSource This function reads the last output source of a module Syntax C short pac GetModuleLastOutputSource
212. s use the pac_GetErrorMessage function For a complete list of error codes see Appendix A System Error Code The following table lists the system error codes ranges for each function reference Error Type Explanation Range PAC_ERR_ SUCCESS 0400000 PAC_ERR_UNKNOWN 0100001 Interrupt 0x13000 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 430 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 10 2 pac_SetLastError This function sets the last error code Syntax C void pac SetLastError DWORD errno Parameters errno in Specifies the last error code Return Value This function has does not return a value Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 431 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Remarks Applications can optionally retrieve the value set by this function by using the pac_GetLastError function The error codes are defined as DWORD values If you are defining an error code ensure that your error code does not conflict with any XPacSDK defined error codes We recommend that your error code should be greater than 0x20000 For more information about the definition of error codes please refer to pac_GetLastError in this document PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 432 Copyright 2013 ICP DAS Co Lt
213. s 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in JThe DO channel to be change DO_ TotalCh in The total number of DO channels of the DO modules iBitValue in 1 is to turn on the DO channel 0 is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 252 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDO_ TotalCh 8 int iBitValue 1 BOOL ret pac_WriteDOBit hPort iSlot iChannel miDO_TotalCh iBitValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iDO_TotalCh 8 int iBitValue 1 BOOL ret pac _WriteDOBit 0 iSlot iChannel miDO_TotalCh iBitValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 253 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDO TotalCh
214. s com 2 7 18 pac_ReadAIlAIll This function reads all the Al values of all channels in engineering mode of the Al module The function maybe causes the buffer overflow in some situation Syntax C BOOL pac _ReadAIAll HANDLE hPort int slot float fValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE _10 0 255 fValue out The array contains the AI values that read back from the AI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 309 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAIl hPort iSlot fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAIl O iSlot fValue CH If themodule is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 float fValue 8 bool iRet PACNET IO ReadAIAll hPort iSlot fValue P
215. s function without any error checking mechanism Checksum CRC LRC etc users have to add the error checking information to the raw data by themselves if communication checking system is required Syntax C bool uart_BinSend HANDLE hPort LPCSTR buf DWORD in Len j Parameters hPort in Handle to the open COM port buf in A pointer to a buffer that send the data in _ Len in The length of result string PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 220 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is 1 If the function fails the return value is O Examples C bool ret HANDLE hPort char buf 2 buf 0 0x41 buf 1 0x42 hPort uart_Open COM4 9600 N 8 1 ret uart_BinSend hPort buf 2 uart_Close hPort C bool ret IntPtr hPort string buf AB hPort XPac Open COM4 9600 N 8 1 ret XPac BinSend hPort XPac AnsiString buf 2 XPac Close hPort Remarks Note that this function is usually applied to communicate with the other device but not for ICPDAS DCON 1 7000 8000 87K series modules This function will call PurgeComm to clear serial COM port output buffer PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 221 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 12 uart_Bi
216. series Easily migrates custom XPAC programs to the WinPAC series A suite of PACSDK APIs is almost same as the previous SDK WinPACSDK dll and XPACSDK_CE dll but there are some modifications and updates Refer to the Appendix C for more details PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 17 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 1 2 Installing the PACSDK The installation package of the XPAC WinPAC platform SDK which supports PACSDK library are available to enable users to develop the applications for the XPAC and WinPAC series Before you install You must uninstall the previous version of XPAC and WinPAC platform SDK before installing the platform SDK installation package whick supports PACSDK library To uninstall the previous version of XPAC and WinPAC platform SDK 1 Click Start click Control Panel and then double click Add or Remove Programs Programs Se Favorites E Documents m Settings FE Control Panel E a Network and Dial up Connections dE Taskbar and Start Menu 2 Inthe Currently installed programs box click the XPACSDK or WinPACSDK item that you want to remove and then click Remove 3 If prompted to confirm the removal of the program click Yes PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 18 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com To install the new i
217. string This is a unicode string will show the console mode correctly Remarks The maximum size of the string buffer is 2 kbytes PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 448 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 5 pac DoEvent pac DoEvents This function handles all events When you run a Windows Form it creates the new form which then waits for events to handle Each time the form handles an event it processes all the code associated with that event All other events wait in the queue While your code handles the event your application does not respond If you Call pac_DoEvents in your code your application can handle the other events Syntax C void pac DoEvents Parameters This function has no parameters Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 449 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int counter O char buf 10 bFlag true while bFlag pac_DoEvents sprintf buf d counter SetDlgltemText IDC_EDIT1 buf counter y PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 450 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 11 6 pac_GetCurrentDirectory This function retrieves the current directory of the
218. t Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 362 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 34 pac GetModuleWDTConfig This function reads the host watchdog status of a module Syntax C bool pac_GetModuleWDTConfig HANDLE hPort int slot short enStatus unsigned long wdtTimeout int ifWDT_ Overwrite PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 363 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE 10 0 255 enStatus out 1 the host watchdog is enabled O the host watchdog is disabled wdtTimeout out The unit of return value is 100ms FWDT_ Overwrite only for i 8k out 1 the host watchdog does overwrite O the host watchdog does no
219. t overwrite Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 364 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int iSlot O short sStatus 0 unsigned long ulWDTtimezO int Overwrite O hPort uart_Open pac GetModuleWDTConfig hPort iSlot amp sStatus amp ulWDTtime amp iOverwrite uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 short sStatus 0 unsigned long ulWDTtime 0 int Overwrite O hPort PACNET UART Open PACNET IO GetModuleWDTConfig hPort iSlot ref sStatus ref ulWDTtime ref iOverwrite PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l S041RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 365 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 35 pac Se
220. tModuleWDTConfig This function enables disables the host watchdog and sets the host watchdog timeout value of a module Syntax C bool pac SetModuleWDTStatus HANDLE hPort int slot short enStatus unsigned long wdtTimeout int ifWDT Overwrite PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 366 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus in 1 the host watchdog is enabled O the host watchdog is disabled wat Timeout in The unit of return value is 100ms FWDT_ Overwrite only for i 8k in 1 the host watchdog does overwrite O the host watchdog does not overwrite Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 367 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort int iSlot O short sStatus 0 unsigned long ulWDTtimezO int Overwrite O hPort uart_Open pac SetModuleWDTConfig hPort iSlot sStatus ulWDTtime Over
221. tStatus PAC_IO GetModuleWDTinterruptStatu Reads interrupt status of a module watchdog S PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 241 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac_SetModuleWDTInterruptStatus PAC_10 SetModuleWDTInterruptStatus Enables disables interrupt of a module watchdog PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 242 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 1 pac_GetBit The function retrieves the value which in specific bit Syntax C BOOL pac GetBit int y int ndx Parameters V Which IO result wants to get bit ndx Specific bit to retrieve Return Value The value of specific index PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 243 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C BYTE bit3 BYTE iSlot 2 int iDl_ TotalCh 8 DWORD IDI_ Value HANDLE hPort hPort uart_Open BOOL iRet pac ReadDl hPort iSlot iDI TotalCh amp IDI_ Value bit3 pac_GetBit IDI Value 3 uart_Close hPort C bool bit int index 3 byte Slot 2 byte Slot 2 int iDl_ TotalCh 8 uint IDI_ Value O IntPtr hPort hPort PACNET UART Open bool iRet PACNET IO ReadDl hPort iSlot iDl_ TotalCh ref IDI Value bit PACNET IO GetBit iDI_
222. tchTypezO DWORD IDI_Latch_ Value BOOL iRet pac_ReadDlLatch O iSlot iDI TotalCh iLatchType amp IDI Latch Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 270 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iDl_ TotalCh 8 int iLatchTypezO uint IDI Latch Value bool iRet PACNET IO ReadDlLatch hPort iSlot iDl_ TotalCh iLatchType ref IDI Latch Value PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE _10 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 271 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 8 pac ClearDlLatch This function clears the latch value of the DI module Syntax C BOOL pac_ClearDlLatch HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function s
223. th another 64KB of SRAM is reserved for use by the system In the previous XPAC SDK XPacSDK_ CE dll all memory space O Ox3FFF 16KB of EEPROM is available for the use by the user and all memory space 070x80000 512KB of SRAM is available for the use by the user PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 477 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 7 Using the new SDK PACSDK in a C program To use the new PACSDK in a C based program some code needs to be changed in the program Replace the previous header file by PACSDK h include WinPacSDK h Changed as include PACSDK h WinPacSDK h is used for both WinPAC or ViewPAC series program and it must be replaced by PACSDK h include XPacSDK_CE h Changed as Hinclude PACSDK h XPacSDK_CE h is used for the XPAC series program and it must be replaced by PACSDK h Replace the previous library file by PACSDK lib WinpacSDK lib WinPAC or ViewPAC series XPacSDK_CE lib XPAC series Changed as PACSDK lib WinPacSDK lib used for WinPAC or ViewPAC series and XPacSDK_CE lib used for XPAC series are replaced by PACSDK lib PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 478 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com The original flowchart for a C program that is calling the previous SDK is illustrated below Project A roject C EXE ARM W
224. the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 The comparison table of pac_WriteAO pac WriteAO MF Functions and available modules are as following Since November 1 2012 l 87024W CW DW RW 1 87024 s702SCW W PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 292 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 14 pac ReadAO This function reads the AO value of the AO module Syntax C BOOL pac _ReadAO HANDLE hPort int slot int iChannel int iAO_ TotalCh float fValue PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 293 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Channel in Read the AO value from the channel AO_ TotalCh in The total number of the AO channels of the AO module float fValue in The pointer to the AO value that is read back from the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 294 Copyright
225. the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 322 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 23 pac ReadCNTOverflow This function clears the counter overflow value of the counter frequency modules Syntax C BOOL pac _ReadCNTOverflow HANDLE hPort int slot int iChannel int iOverflow Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC REMOTE_IO 0 255 iChannel in The channel that reads the counter overflows value back from the counter freguency module iOverflow out The pointer to the counter overflow that is read back from the counter freguency module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 323 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples eVC VC VS Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iCh
226. turn Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 260 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_ReadDI Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 2 int iDl_ TotalCh 8 DWORD IDI_ Value BOOL iRet pac_ReadDI hPort iSlot iDl_ TotalCh amp IDI_ Value uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 2 int iDl_ TotalCh 8 DWORD IDI_ Value BOOL iRet pac_ReadDI 0 iSlot iDI TotalCh amp IDI Value C pac_ReadDI_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 2 int iDl_ TotalCh 8 DWORD IDI Value BOOL iRet pac_ReadDl_MFf hPort iSlot iDI_ TotalCh amp IDI_ Value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 261 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com CH pac_ReadDI f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 int iDl_ TotalCh 8 uint IDI_ Value bool iRet PACNET IO ReadDI hPort iSlot iDl_ TotalCh ref IDI Value PACNET UART Close hPort CH pac ReadDl_MF f the module is 87k local IntPtr hPort hPort PA
227. turn a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 66 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C char OS 32 pac _GetOSVersion OS C string OS OS PACNET Sys GetOSVersion PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 67 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 9 pac GetMacAddress This function retrieves the MAC address of Ethernet adapter of WinPAC XPAC series device Syntax C void pac GetMacAddress BYTE LAN LPSTR MacAddr Parameters LAN in Specifies the LAN number which you want to use MacAddr out Retrieves the MAC address Return Value This function does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 68 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C char MAC 32 BYTE LAN 1 pac_GetMacAddress LAN MAC CH byte MAC 1 String LAN LAN PACNET Sys GetMacAddress MAC PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 69 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 1 10 pac ReBoot This function reboots the OS Syntax C void pac ReBoot Parameters This function has no parameters Return Value This function does not return a value
228. ucceeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 272 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac_ClearDlLatch hPort iSlot uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 BOOL iRet pac_ClearDlLatch O iSlot CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 bool iRet PACNET IO ClearDlLatch hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 273 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 9 _ pac ReadDlOlatch This function reads the latch values of the DI and DO channels of the DIO module Syntax C BOOL pac _ReadDIOLatch HANDLE hPort int slot int iDI TotalCh int iDO_TotalCh int iLatchType DWORD IDI Latch_ Value DWORD IDO Latch Value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 274 Copyright
229. ue If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 256 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac ReadDO Example 1 If the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_value BOOL ret pac ReadDO hPort slot total channel amp do_ value uart_Close hPort Example 2 If the module is 8k local BYTEslot 1 int total channel 8 DWORD do value BOOL ret pac_ReadDO O slot total channel amp do_value C pac ReadDO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_ value BOOL ret pac_ReadDO_MF hPort slot total channel amp do_ value uart_Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 257 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_ReadDO If the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do_value bool ret PACNET IO ReadDO hPort slot total channel ref do_value PACNET UART Close hPort CH pac ReadDO MF f the module is 87k local IntPtr hPort hPort PACNET UART
230. ue is FALSE Remarks The definition of the parameters and Return Value of pac _WriteDO and pac_WriteDO MF functions are the same The different is that pac_WriteDO is applied to the pure DIO DCON modules and pac _WriteDO MF is applied to the Multi function DCON modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 246 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac_WriteDO Example 1 If the module is remote HANDLE hPort hPort uart Open COM2 9600 N 8 1 int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteDO hPort PAC REMOTE _IO 1 total channel do_ value uart_Close hPort Example 2 If the module is 87k local HANDLE hPort hPort uart_Open int total_ channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteDO hPort 1 total channel do value uart_Close hPort Example 3 If the module is 8k remote int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteDO O 1 total channel do_value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 247 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C pac_WriteDO_MF Example 1 f the module is remote HANDLE hPort hPort uart Open COM2 9600 N 8 1 int total channel 8 DWORD do v
231. ue is FALSE To get extended error information call GetLastError to obtain the last error ocde of Windows API PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 453 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C TCHAR buf 1024 pac_GetCurrentDirectory buf 1024 PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 454 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix A System Error Codes This following table provides a list of system error code There are turned by the pac_GetLastError function when many functions fail To retrieve the description text for the error in your application use the pac_GetErrorMessage function Error Code Error Message PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 455 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 456 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix B API Comparison The following tables give a brief summary of the capabilities of each API function where Y means supported and X means unsupported System Information Functions XP 8000 Atom CE6 WP 8x4x Functions Models XP 8000 CE6 WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx Y lt pac GetMacAddress Y PAC Standard API
232. ue to read to the PWM module PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 388 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 unsigned long ulfreg BOOL iRet pac_GetPWMFrequency hPort iSlot iChannel amp ulfreg uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong ulfreg 1 bool iRet PACNET PWM GetPWMFrequency hPort iSlot iChannel ref ulfreq PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 389 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 5 pac SetPWMMode This function sets the continuous mode for a specific channel Syntax C bool pac SetPWMlMode HANDLE port int slot short chindex long mode Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel mode in O Disabl
233. uilding and the built executable file placed in the XPAC series device must work with PACSDK dll VC Project Link C EXE ARM PACSDK lib The CH VB net project required to refer to PACNET dll while building and the built executable file placed in the XPAC series device must work with PACNET dll and PACSDK dll CH VB net A net EXE Project Link PACNET dll PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 496 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix E How to upgrade the WinPACSDK dll XPACSDK dll Questions related to updating the PACSDK library from the WinPacSDK library and the solutions Refer to w6 10 How _ to update to PACSDK library from WinPacSDK library_en pdf located at http fto Icodas com pub cd winpac napdos wp 8x4x ce50 document fag sdk w6 10 how to update to pacsdk library from winpacsdk library en pdf Questions related to updating to PACSDK library from the XPacSDK library and solutions Refer to x6 10 How to update to PACSDK library from XPacSDK library_en pdf located at http fto icpdas com pub cd xp 8000 ce6 document fag sdk x6 10 how to update to pac sdk library from xpacsdk library en pdf PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 497 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Appendix F Comparison of Defined Slots and COM Ports Each PAC has
234. uilt as two different platform executable programs selecting the different Platform settings in the development environment while build the project The results of the above are Project is built as an ARM based executable program which runs with the ARM based PaCSDK dll and it s also built as an x86 based executable program which runs with x86 based PaCSDK dll PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 480 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com C 2 PACNET SDK modifications and updates The NET Compact Framework environment allows multiple high level languages C VB to be used on different platforms without needing to be rewritten for specific architectures The new PACNET dll replaces the previous NETCF SDK WinPacNet dll and XPacNet dll files which means that NET CF programs linking to the PACNET dll on a WinPAC device can be migrated to a XPAC device without needing to rewrite the code or rebuild the project and vice versa 1 PAC Standard API Manual v1 1 1 API function classification manual are as follows Classification in the API Manual 2 1 System Information API 2 1 Buzzer API 2 2 Interrupt API 2 3 Memory Access API 2 4 Watchdog API 2 5 Registry API 2 6 UART API 2 7 PAC_IO API 2 8 PWM API 2 9 Backplane Timer API 2 10 Error Handling API 2 11 Misc API All API functions for the WinPacNet dil or the XPacNet dll are pla
235. ule PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 386 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE Examples C Example 1 1f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 unsigned long ulfreq 1 BOOL iRet pac _SetPWMFrequency hPort iSlot iChannel ulfreg uart_Close hPort C IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong ulfreq 1 bool iRet PACNET PWM SetPWMFrequency hPort iSlot iChannel ulfreq PACNET UART Close hPort PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 387 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 4 pac_GetPWMFrequency This function reads the frequency value for a specific channel Syntax C bool pac GetPWMFreguency HANDLE port int slot short chindex unsigned long freq Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Set the duty cycle value from the channel freq in The frequency val
236. um bytes to the end of data which is used to produce checksum Syntax C void uart_EnableCheckSum HANDLE hPort BOOL bEnable Parameters hPort in Handle to the open COM port bEnable in Decide the check sum turning on or not Default is disabling Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 216 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C HANDLE hUart char result 32 hUart uart Open uart_EnableCheckSum hUart true pac ChangeSlot 1 uart_SendCmd hUart SOOM result CH byte result new byte 32 IntPtr hPort PACNET UART Open PACNET UART EnableCheckSum hPort true PACNET Sys ChangeSlot 1 PACNET UART SendCmd hPort XPac AnsiString SOOM result string str PACNET MISC WideString result PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 217 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 6 10 uart_SetTerminator This function sets the terminate characters Syntax C void uart_SetTerminator HANDLE hPort LPCSTR szTerm Parameters hPort in Handle to the open COM port szlerm in Pointer the terminate characters Default is CR Return Value This function has does not return a value PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 218 Co
237. unction deletes the registry key after turning off the hot plug Syntax C void pac UnregistryHotPlug DWORD hWnd Parameters hWnd in Specifies the handle ID Return Value This function does not return a value Examples This function has no examples PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 101 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 Interrupt API The Interrupt functions provide the slot interrupt that may be used for counting timing detecting external events and sending and receiving data using the serial interface Interrupt Flow 0 Rising edge 1 Level trigger 2 Falling edge _ Step 1 Set tigger type Program Start Y Y pac_SetTriggerType Slot 1 Step 2 Install user callback function pac_RegisterSlotlnterrupt Slot f Step 3 Set interrupt priority pac_SetSlotInterruptPriority Slot Priority Step 4 Enable Interrupt pac_EnableSlotinterrupt Slot true int CALLBACK REO return PAC INTR_DONE pac_EnableSlotinterrupt gislot false pac_UnregisterSlotlnterrupt BYTE slot PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 102 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the interrupt functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xx
238. us O pac_SetModuleWDTInterruptStatus iSlot sStatus C int iSlot 0 short sStatus O PACNET IO SetModuleWDTlnterruptStatus iSlot sStatus Remarks I 8K series modules provided with Power ON or Safe Value function can support this API function At present only I 8041RW has this feature in all I 8K modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 378 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 PWM API PWM API only supports to operate I 7K I 87K PWM modules Before using the PWM API functions refer to the previous chapter PAC_IO Reference first for more details regarding of the slot definition in local and how to use remote I O module In developing C C program for I 7K I 87K PWM modules connected or plugged to on the the WinPAC XPAC series device in addition to link PACSDK lib and it needs to link PACSDK_PWM lib to the user s project Besides the built executable file placed in the WinPAC XPAC series device must work with PACSDK dll and PACSDK_PWM dll In developing net CF program the project only refer to PACNET dll and the built executable file placed in the WinPAC series device only works with PACNET dll and PACSDK all For more information about I 7K l 87K PWM modules that are compatible with the XPAC WinPAC series please refer to I 87K series www icpdas com products PAC i 8000 8000 IO modules htm i87k PWM module such as 8
239. utable file placed in the WinPAC series device must work with PACNET dll and PACSDK dll CH VB net ease eee net EXE Project Link PACNET dll PC WinPAC PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 493 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Notes 1 Multi function DCON modules are defined as modules that mainly act as AIO or Counters but are equipped with DIO channels Such as the 87005W 1 87016W 1 87082W 1 7016 1 7088 etc 2 Old DCON module definition Non multi function DCON modules are defined as Old DCON modules PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 494 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 On XPAC devices i _ The users have used XPAC series devices and their programs is based on the old SDK XPacSDK_CE dll XPacNet dll working with the old DCON modules Note 2 on XPAC device and without using multi function DCON modules Note 1 The user s program can continue to use the old library without needing to be modified The Old SDK will continue to maintain Fix the bugs and released regularly but will not add new features Use the old SDK as following flowchart The VC project required to link XPacSDK_CE lib while building and the built executable file placed in the XPAC series device must work with XPacSDK_ CE dll VC Project Link C EXE ARM
240. write uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 short sStatus 0 unsigned long ulWDTtime 0 int Overwrite O hPort PACNET UART Open PACNET IO SetModuleWDTConfig hPort iSlot sStatus ulWDTtime iOverwrite PACNET UART Close hPort Remarks 1 The function can support for Local or Remote When the module is local the second Parameter s range is from O to 7 If remote the second Parameter need use the macro PAC REMOTE_IO 0 255 which range is from O to 255 2 _ l 7K l 87K series modules provided with Power ON or Safe Value function can support this API function I 8K series module provided the functions is only l SO41RW PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 368 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 7 36 pac ResetModuleWDT This function resets the host watchdog timeout status of a module Syntax C bool pac_ResetModuleWDT HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1
241. x VP 25Wx VP 23Wx pac Unregisterslointermpt Y Y YT pac Enableslotintermpt Y Y YP op op lt lt lt lt lt lt lt lt lt lt lt lt lt lt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 103 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Interrupt Functions The following functions are used to retrieve or set the slot interrupt PACSDK Functions PACNET Functions Description pac_RegisterSlotlnterrupt Interrupt RegisterSlotlnterrupt Registers the slot interrupt service route after turning on the slot interrupt Interrupt UnregisterSlotlnterrupt Unregisters slot interrupt service route and disables a hardware interrupt as specified pac_UnregisterSlotinterrupt by its interrupt identifier pac_EnableSlotinterrupt Interrupt EnableSlotlnterrupt Performs hardware operations necessary to enable the specified hardware interrupt pac_SetSlotInterruptPriority Interrupt SetSlotlnterruptPriority Sets the priority for a real time thread on a thread by thread basis WN Interrupt Interruptinitialize Initializes a slot interrupt with the kernel This initialization allows the slot to register pac_Interruptinitialize an event and enable the interrupt PAC Standard API Manual v1 1 1 Last Revised Dec 2013 Page 104 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 2 1 _ pac Reg

Download Pdf Manuals

image

Related Search

Related Contents

Ayre AX-7e Manual  NP RapidDial Reference Manual  George Foreman GGR62 Use & Care Manual  Torqeedo Travel 503/1003  カーセキュリティ用OBDⅡアダプター適応表  Volltext  none 4419675 Instructions / Assembly  DI-155 USB Data Acquisition Starter Kit  signalling systems rato 6  取扱説明書 取扱説明書  

Copyright © All rights reserved.
Failed to retrieve file