Home

XPAC/PC - ICP DAS

image

Contents

1. PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 17 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com To Update the XPACSDK DCON_PC 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 icpdas com pub cd winpac napdos wp 8x4x ce50 document faa 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 faa sdk or http ftp icpdas com pub cd xpac atom ce6 document fag sdk PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 18 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 Setting up the Development Environment Although 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 0 Last Revised Jan
2. lt lt lt lt lt lt lt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 42 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com pac_ReBoot Pac_EnableLED pac_BackwardCompatible pac_GetEbootVersion 2 z pac GetComMapping lt lt lt lt lt lt lt lt lt lt lt lt lt lt Beta testing pac_RegistryHotPlug Beta testing pac_UnregistryHotPlug PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 43 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com System Information Functions The following functions are used to retrieve or set system information PACSDK Functions pac GetModuleName PACNET Functions Sys GetModuleName Description retrieves the name of the specified I O module plugged into the XPAC series devices pac GetRotaryID Sys GetRotaryID retrieves the position number of the rotary switch pac GetSerialNumber Sys GetSerialNumber retrieves the serial number of the XPAC hardware ID pac_GetSDKVersion Sys GetPacSDKVersion retrieves the version number of the current PACSDK dll pac_ChangeSlot Sys ChangeSlot handles the slot of the XPAC from one to
3. Excel Controls 5 Dialog Editor ci All Windows Forms P DE Pointer Cj Background Worker 159 BindingNavigator 53 BindingSoure CheckBox EZ CheckedListBox ColorDialog ComboBox fe ContextMenuStrip iJ DataGrid View is DataSet T Date TimePicker 5s DirectoryEntry sil Step 4 In order to use Dillmport you should add the namespace using Statement System Runtime InteropServices and then implement the function which you want to call Demonstrate an example of using pac writeDO in NET project The function defined in PACSDK h file PAC API BOOL pac WriteDO HANDLE hPort int slot int iDO TotalCh DWORD I IDO Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 32 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com How to use in your NET project 1 Added this line in your project lt Dlllmport PACSDK dll EntryPoint pac_WriteDO gt _ Public Shared Function pac_WriteDO ByVal hPort As IntPtr ByVal slot As Integer ByVal I iDO TotalCh As Integer ByVal IDO Value As Ulnteger As Boolean I End Function 3 Then you can use this function pac WriteDO in your NET project Code Snippet Public Class Form1 Inherits Form Dllimport PACSDK dll EntryPoint pac_WriteDO gt _ Public Shared Function pac WriteDO ByVal hPort As IntPtr ByVal slot As Integer ByVal iDO
4. gt lt E mail service icpdas com 2 7 22 pac_ClearCNT This function 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 0 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 295 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int ichannel 0 BOOL iRet pac_ClearCNT hPort iSlot iChannel uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 0 BOOL iRet pac ClearCNT O iSlot iChannel CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int ichannel 0 bool iRet PACNET IO ClearCNT hPort iSlot iChannel PACNET
5. name V Create directory for solution Step 3 Copy PACSDK h to the application folder and include it 1 Copy PACSDK h to the application folder 2 Add include PACSDK h include stdafx h include Form1 h include PACSDK h PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 21 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 4 Copy PACSDK lib to the application folder and Include it 1 Copy PACSDK lib to the application folder 2 Open the project s Property Page dialog box 3 Click the Linker folder 4 Clickthe Input property page 5 Inthe right pane type the PACSDK lib in the Additional Dependencies item Sample Property Pages Acive Debug E Common Properties Additional Dependencies B PACSDK lib mE 5 Configuration Properties Ignore All Default Libraries No eneral Ignore Specific Lib Dabisa gnore Specific Library x CAC Module Definition File Linker Add Module to Assembly Embed Managed Resource File Manifest File Force Symbol References Debugging Delay Loaded DLLs Sou Assembly Link Resource Optimization Embedded IDL Advanced Command Line Manifest Tool Resources Managed Resources H XML Document Generator Browse Information j Build Events amp Custom Build Step Additional Dependencies Specifies additional items to add to the link line ex kemnel 2 lib
6. C int fq 0 int du 0 pac GetBuzzerFregDuty amp fq amp du CH int fq 0 int du 0 PACNET Sys Buzzer GetBuzzerFreqDuty ref fq ref du Console WriteLine The frequency fq ToString The duration du ToString Console ReadLine The example displays the following output to the console The frequency 2000 The duration 50 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 74 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 14 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 duty cycle of the sound Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 75 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int fq 500 int du 20 pac SetBuzzerFregDuty fq du CH Set Frequency 100 and Duty Cycle 20 int fq 100 int du 20 PACNET Sys Buzzer SetBuzzerFreqDuty fq du Remark The default frequency value is 2000 and the default duty cycle value is 50 in PACSDK dll You can use the pac_SetBuzzerFreqDuty function to change the two parameters and the two values you
7. pac InitModuleWDTInterrupt PAC IO InitModuleWDTInterrupt initializes and enables interrupt of a module watchdog pac GetModuleWDrTlInterruptStatus PAC 10 GetModuleWDTInterruptStatu reads interrupt status of a module watchdog PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 215 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com pac SetModuleWDrTInterruptStatus PAC 10 SetModuleWDTInterruptStatus enables disables interrupt of a module watchdog PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 216 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 v 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 217 Examples C BYTE bit3 BYTE iSlot 2 int iDI_TotalCh 8 DWORD Value HANDLE hPort hPort uart Open bit3 pac_GetBit IDI_ Value 3 uart_Close hPort bool bit int index 3 byte iSlot 2 byte iSlot 2 int iDI_TotalCh
8. Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode PACNET UART Close hPort BOOL iRet pac_GetPWMSynChannel hPort iSlot iChannel amp mode bool iRet PACNET PWM GetPWMsSynChannel hPort iSlot iChannel ref mode PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 377 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 12 pac SyncPWMStart This function starts the PWM synchronization 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 module is remote please use the macro PAC REMOTE 0 255 enStatus in 0 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 0 Last Revised January 2013 Page 378 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f
9. PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 318 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C 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 ref do_value PACNET UART Close hPort Remarks bool ret PACNET IO pac ReadModulePowerOnValueDO MrF hPort slot total channel 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 1O 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 319 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 OpenY 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 module is remote please use the macro PAC REMOTE 0 255 iChannel in The channel that is written thee AO value to iAO TotalCh in The to
10. The number of subkeys is 8 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 135 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 LPCSTR 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 136 Examples C DWORD i i pac_RegCountValue TEXT HKEY_USERS myKey CH uint i i PACNET PAC_Reg RegCountValue HKEY_USERS myKey Console WriteLine The number of values is i ToString Console ReadLine The example displays the following output to the console The number of values is 3 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 137 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 3 pac_RegCreateKey This function creates the specified registry key Syntax C BOOL pac_RegCreateKey LPCSTR KeyName Parameters KeyName in Specific the path of registry key which you want to create Return Value Return true if success
11. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 PWM API PWM API only supports to operate 7 87 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 3dll 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 dll For more information about 7 87 PWM modules that are compatible with the XPAC WinPAC series please refer to 1 87K series http www icpdas com products PAC i 8000 8000 IO modules htm i87k PWM module such as I 87088W module I 7K series 000 selection html such as 7088 The suit of the PWM API functions isn t applied to the 8 PWM module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 353 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PWM functio
12. BYTE iSlot 1 int iChannel 2 short mode 0 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode 0 PACNET UART Close hPort BOOL iRet pac_SetPWMSynChannel hPort iSlot iChannel mode bool iRet PACNET PWM SetPWMSynChannel hPort iSlot iChannel mode PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 375 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 11 pac_GetPWMSynChannel This function reads the PWM synchronization status for a specific channel Syntax C bool pac_GetPWMSynChannel HANDLE port int slot short chlndex 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 376 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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
13. 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 all ARM is used on WinPAC series and PACSDK dll x86 is used for XPAC series PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 459 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service 2icpdas 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 0 Last Revised January 2013 Page 460 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 5 Show a tooltip for the classes of PACNET dIl 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 giving not only the parameters and variables of methods but also some descriptions for these methods classes and namespaces Those description of tooltips
14. Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 VP 25Wx VP 23Wx AnsiString X X Y Y Y Y Y Y WideString X X Y Y Y Y Y Y pac AnsiToWideString Y Y Y Y Y Y Y Y pac WideToAnsiString pac Y Y Y Y Y Y y y WideStringToAnsi pac_DoEvent pac_DoEvents Y Y Y Y Y Y Y Y pac_GetCurrentDirectory X X Y Y Y Y Y Y pac GetCurrentDirectoryW X X Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 413 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Misc Functions The following functions are used to retrieve or set the memory PACSDK Functions AnsiString MISC AnsiString converts a unicode string to an ANSI byte array WideString MISC WideString converts an ANSI byte array to Unicode string pac AnsiToWideString N A converts an ANSI string to a Unicode string pac WideToAnsiString pac WideStringToAnsi N A converts a Unicode string to an ANSI string pac DoEvent pac DoEvents N A handles all events pac GetCurrentDirectory MISC GetCurrentDirectory retrieves the current directory of the Char data type for the current application N A retrieves the current directory of the TCHAR data type for th
15. Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 267 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AO value from the channel 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 0 Last Revised January 2013 Page 268 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 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
16. 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 CH This example demonstrates how to change slot if you want to use the uart API byte slot IntPtr hPort bool ret byte buf new byte 10 hPort PACNET UART Open Assign the slot number and change to the slot which the 87k modules plug in slot 1 PACNET Sys ChangeSlot slot Send SOOM DCON command by uart API to get the module name ret PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM buf Console WriteLine The Module on slot 1 is PACNET MISC WideString buf Console ReadLine The example displays the following output to the console The Module Name on slot 1 is 87061 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 55 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks When you use uart APIs and the IO modules are located as slots you have to call pac ChangeSlot to the specified slot for communicating with the module 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 0 Last Revised January 2013 Page 56 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
17. in The slot in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 343 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 0 hPort uart_Open pac_ResetModuleWDT hPort iSlot uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open PACNET IO ResetModuleWDT 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 344 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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
18. local slot in The slot in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 345 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 0 hPort uart_Open pac_RefreshModuleWDT hPort iSlot uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open PACNET IO RefreshModuleWDT 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 346 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 modul
19. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 int iSlot 0 short sStatus 0 sStatus pac GetModuleWDTInterruptStatus iSlot CH int iSlot 0 short sStatus 0 sStatus PACNET IO GetModuleWDTInterruptStatus iSlot PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 350 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 351 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 int iSlot 0 short sStatus 0 pac_SetModuleWDTInterruptStatus iSlot sStatus CH int iSlot 0 short sStatus 0 PACNET IO SetModuleWDTiInterruptStatus iSlot sStatus PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 352 Copyright
20. BOOL pac_WriteDOBit HANDLE hPort int slot int iDO TotalCh int iChannel int iBitValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 225 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The DO channel to be change TotalCh in The total number of DO channels of the DO modules iBitValue in 1 is to turn on the DO channel O 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 0 Last Revised January 2013 Page 226 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Example 1 f 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 Channel 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
21. BOOL ret uart_GetLineStatus hPort DSR the pin DSR for example PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 202 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 define IN DATA 0 define OUT DATA 1 Return Value The number of bytes in out buffer but not yet read write PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 203 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 16 uart_SetLineStatus This function sets the status of modem line Syntax C DWORD uart SetLineStatus HANDLE hPort int pin int mode y 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 DTR 1 define RTS 2 define DTR RTS 3 mode in 0 Disable Set the pin signal is OFF 1 Enable Set the pin signal is ON PAC Standard API Manual v1 1 0 Last Revised
22. C DWORD pac_RegGetKeyInfo LPCSTR KeyName Parameters KeyName in Specific the path of registry key Return Value We define four types about the return value 0 PKT NONE 1 PKT KEY 2 PKT STRING 3 PKT DWORD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 148 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C DWORD dwType dwType pac_RegGetKeyInfo TEXT HKEY_USERS myKey value CH uint uType uType PACNET PAC Reg RegGetKeyInfo HKEY CURRENT USERWmyKeyWNvalue Console WriteLine The type is uType Console ReadLine The example displays the following output to the console The type is 2 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 149 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 9 pac_RegGetString This function retrieves the value of the specified registry key Syntax C bool pac_RegGetString LPCSTR KeyName LPSTR IpData DWORD dwLength y Parameters KeyName in Specify the path of registry key lpData out Pointer to a buffer that receives the data of the value dwLength in Specify 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 descr
23. PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 93 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 Last Revised January 2013 Page 94 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 5 pac Interruptlnitialize 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_Interruptlnitialize 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 function fails the return value is FALSE To get extended error information call pac_GetLastError Examples This functio
24. int iChannel 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 0 Last Revised January 2013 Page 324 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 325 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 by uart OpenY 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 module is remote please use the macro PAC REMOTE 0 255 iChannel in The channel that is written thee AO value to 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 Sta
25. lt XP 8000 Atom CE6 lt WP 8x4x lt WP 8x3x lt WP 8x5x lt WP 5xxx lt VP 25Wx lt VP 23Wx lt pac_WriteDO pac_WriteDO_MF pac_WriteDOBit pac_ReadDO pac_ReadDO_MF pac_ReadDI pac_ReadDI_MF pac_ReadDIO pac_ReadDIO_MF pac_ReadDILatch pac ClearDILatch pac ReadDlOLatch pac ClearDlOLatch pac ReadDICNT pac ReadDICNT MF pac ClearDICNT pac ClearDICNT MF pac WriteAO pac WriteAO MF lt lt lt lt lt lt lt XR XR lt lt lt lt lt lt lt XR XR X lt lt lt lt lt lt lt XR XR lt lt lt lt lt lt lt XR XR lt lt lt lt RE XR XR XR X lt lt lt lt lt lt lt XR XR lt lt lt lt lt lt lt XR lt lt lt lt lt lt lt lt lt lt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 438 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com pac_ReadAO Y Y Y Y Y Y Y Y pac_ReadAl Y Y Y Y Y Y Y Y pac_ReadAlHex Y Y Y Y Y Y Y Y pac ReadAIAIIExt Y Y Y Y Y Y Y Y pac ReadAIAII Y Y Y Y Y Y Y Y pac ReadAIAIIHexExt Y Y Y Y Y Y Y Y pac ReadAIAIIHex Y Y Y Y Y Y Y Y pac ReadCNT Y Y Y Y Y Y Y Y pac C
26. pac KillBPTimer 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_GetLastError Y Y Y Y Y N Y Y pac_SetLastError Y Y Y Y Y N Y Y pac_GetErrorMessage Y Y Y Y Y N Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 442 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_ClearLastError Y Y N N N N N Y Misc Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx AnsiString X X Y Y Y Y Y Y WideString X X Y Y Y Y Y Y pac_AnsiToWideString Y Y Y Y Y Y Y Y pac_WideToAnsiString pac_ y y Y y y T WideStringToAnsi pac_DoEvent pac_DoEvents Y Y Y Y Y Y Y Y pac_GetCurrentDirectory X X Y Y Y Y Y Y pac_GetCurrentDirectoryW X X Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 443 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 444 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1
27. ret PACNET UART BinSendCmd hPort cmd 2 buf 2 PACNET UART Close hPort Remarks This function will call PurgeCommY to clear serial COM port output and input buffer PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 200 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 14 uart_GetLineStatus This function retrieves the modem control register values Syntax SO ug BOOL uart_GetLineStatus HANDLE hPort int pin y 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 0 define DSR 1 Hdefine RI 2 Hdefine CD 3 Return Value TRUE indicates the pin s state is ON O indicates OFF PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Page 201 gt lt E mail service icpdas com Examples C HANDLE hPort uart_Open COM5 115200 N 8 1 if ret printf The status of DSR is ON n else printf The status of DSR is OFF n uart_Close hPort CH 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 IntPtr hPort PACNET UART Open COMS5 115200 N 8 1
28. while true Console WriteLine Press any key to refresh the watchdog in 10 Seconds Console ReadLine PACNET Sys WDT RefreshWatchDog 1 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 124 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 4 pac GetWatchDogsState This function retrieves the watchdog state Syntax C BOOL pac_GetWatchDogState int wdt Parameters wat in Specifies the Watchdog type 0 Hardware watchdog PAC_WDT_HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PAC_WDT_OS Return Value If the watchdog is turning on and the return value is TRUE Otherwise the return value is FALSE PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 125 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL bState bState pac_GetWatchDogState PAC_WDT_OS CH bool bState bState PACNET Sys WDT GetWatchDogstate 1 Console WriteLine The state of the watchdog is bState ToString Console ReadLine f the watchdog is enabled the output to the console is as below F The state of the watchdog is true f the watchdog is disabled the output to the console is as below The state of the watchdog is false PAC Standard API Manual v1 1 0 Last Revised January 2013 Pa
29. 7 COM3 mt RS 485 c PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 474 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 3 XP 8141 Atom CE6 COMS RS 232 4 RS 232 RS 485 COM RS 232 COM1 Slot 1 COM3 r7 RS 485 1 gt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 475 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 4 XP 8341 Atom CE6 XP 8741 Atom CE6 COM4 RS 232 RS 485 COMS RS 232 COM2 RS 232 XP 8341 Atom CE6 COM Slot 1 3 XP 8741 Atom CE6 COM Slot 1 7 COM3 RS 485 p PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 476 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 5 WP 81x1 gt COM2 RS 485 w COMI ap 39 232 COMO Slot 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 477 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 6 WP 84x1 WP 88x1 COM3 RS 232 RS 485 coma RS 232 COM1 RS 232 WP 84x1 COMO Slot 0 3 WP 88x1 COMO Slot 0 7 COM2 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 478 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F
30. 81 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 19 pac_GetBatteryLevel This function retrieves the battery status of the backplane and the RTC battery status of the CPU board This function supports the following series models XPAC Syntax C int pac_ GetBatteryLevel int nBattery PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 82 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 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 Return Value 1 means high voltage 0 means low voltage for XPAC series only Examples C int nBattery int index 1 nBattery pac_GetBatteryLevel index CH int nBattery int index 1 nBattery PACNET Sys GetBatteryLevel index Console WriteLine The First battery level is nBattery ToString Console ReadLine The example displays the following output to the console The First battery level is 1 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 83 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 20 pac_EnableRetrigger This function determines the retrigger status Syntax C void pac_EnableRetrigger BYTE iValues Parameters iValue
31. BOOL ret pac WriteDOBit 0 iSlot iChannel miDO TotalCh iBitValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 227 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 8 int iBitValue 1 PACNET UART Close hPort Remarks bool ret PACNET IO WriteDOBit hPort iSlot iChannel miDO TotalCh iBitValue 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 1O 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 228 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 TotalCh DWORD IDO Value Lh 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 0 Last Revised January 2013 Page 229 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial
32. January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Page 170 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 if you call pac GetErrorMessage it could fail Examples C HANDLE hOpen hOpen uart Open COM1 9600 N 8 1 CH IntPtr hOpen hOpen PACNET UART Open COM1 9600 N 8 1 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 171 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 1I 811xW 1 814xW series modules The COM port name is COM6 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 I 811xW I 814xW series modules Please refer to the manual below w1 007 1 how to set up a communication module l 8112 8114 8142 1 8144 use COM english pdf w1 007 2 how to set up a communication module I
33. January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 204 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 CH 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 1 0 Last Revised January 2013 Page 205 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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_Open Clear DO pac WriteDO wort TS1oE ino Tot
34. PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 278 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 17 pac ReadAIAIIExt This function reads all the AI values of all channels in engineering mode of the Al module This function replaces pac ReadAIAIl Syntax C BOOL pac ReadAIAII HANDLE hPort int slot float fValue DWORD Buff Len DWORD Channel PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 279 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 fValue out The array contains the Al values that read back from the Al 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 succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 0 Last Revised January 2013 Page
35. 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 Project XPacSDK CE dll o PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 469 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 building and the built executable file placed in the XPA
36. iChannel mode bool iRet PACNET PWM SetPWMDITriggerConfig hPort iSlot iChannel mode PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 369 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 8 pac _GetPWMDITriggerConfig This function reads the hardware trigger for a specific channel Syntax C bool pac GetPWMDlITriggerConfig HANDLE port int slot short chlndex short config 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel config out 0 Disables the hardware trigger 1 Enables the trigger start 2 Enables the trigger stop PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 370 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int i
37. 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 0 Last Revised January 2013 Page 191 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 szTerm in Pointer the terminate characters Default is CR Return Value This function has does not return a value PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Page 192 Examples C HANDLE hPort char result 32 uart SetTerminator hPort r pac ChangeSlot 0 A I 87K module is in slotO uart Close hPort CH byte result new byte 32 device name DCON string str PACNET MISC WideString result PACNET UART Close hPort Remarks hPort uart Open Open COMO data format 115200 N 8 1 uart SendCmd hPort SOOM result SOOM ask the device name DCON IntPtr hPort PACNET UART Open Open COMO
38. 184 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 185 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C 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 CH 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 0 Last Revised January 2013 Page 186 Cop
39. 2013 Page 231 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do_value PACNET UART Close hPort C pac_ReadDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do_value PACNET UART Close hPort Remarks bool ret PACNET IO ReadDO hPort slot total channel ref do value bool ret PACNET IO ReadDO MF hPort slot total channel ref do value 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 232 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 5 pac ReadDl 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 ReadDI MF HANDLE hPort int slot int iDI TotalCh DWORD IDI Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 233 Copyright 2013 ICP D
40. 280 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int ichannelnumber 0 hPort uart_Open BYTE iSlot 1 float fValue 8 uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int ichannelnumberz0 float fValue 8 CH f the module is 87k local IntPtr hPort Int channelnumber 0 hPort PACNET UART Open byte iSlot 1 float fValue 8 PACNET UART Close hPort BOOL iRet pac_ReadAIAIlExt hPort iSlot fValue 8 amp ichannelnumber BOOL iRet pac ReadAIAIIExt 0 iSlot fValue 8 amp ichannelnumber bool iRet PACNET IO ReadAIAIIExt hPort iSlot fValue 8 ref channelnumber PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 281 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 282 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 18 pac ReadAIAII This function reads all the AI values of all channels in engineering mod
41. 390 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 391 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 Standard API Manual v1 1 0 Last Revised January 2013 Page 392 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 applic
42. API Manual v1 1 0 Last Revised January 2013 Page 367 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 chlndex short config 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel config in 0 Disables the hardware trigger 1 Enables the trigger start 2 Enables the trigger stop PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 368 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannelz2 short mode 0 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 short mode 0 PACNET UART Close hPort BOOL iRet pac_SetPWMDITriggerConfig hPort iSlot
43. API Manual v1 1 0 Last Revised January 2013 Page 62 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char OS 32 pac_GetOSVersion OS CH string OS OS PACNET Sys GetOSVersion Console WriteLine The XPAC OS version is v OS Console ReadLine The example displays the following output to the console The XPAC OS version is v1 0 3 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 63 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 9 Pac_GetCPUVersion This function retrieves the version number of the XPAC CPU board Syntax C void pac GetCPUVersion LPSTR cpu version Parameters cpu version out The version number of the XPAC CPU board Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 64 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char CPU 32 pac_GetCPUVersion CPU CH string CPU PACNET Sys GetCPUVersion Console WriteLine The XPAC CPU board version is v CPU Console ReadLine The example displays the following output to the console The XPAC CPU board version is v1 0 15 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 65 Copyright 2013 ICP DAS Co L
44. Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret ret pac RegDeleteKey TEXT HKEY USERSWmyKeyNV CH bool ret ret PACNET PAC_Reg RegDeleteKey HKEY_CURRENT_USER myKey Remarks 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 0 Last Revised January 2013 Page 141 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 LPCSTR 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 0 Last Revised January 2013 Page 142 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret ret pac RegDele
45. D lt E mail service icpdas com 0x14009 Uart internal buffer overflow 0x15001 IO card does not support this API function 0x15002 API unsupport this IO card 0x15003 Slot s value exceeds its range 0x15004 Channel s value exceeds its range 0x15005 Gain s value exceeds its range 0x15006 Unsupported interrupt mode 0x15007 I O value is out of the range 0x15008 I O channel is out of the range 0x1500A DI O channel can t overwrite 0x1500B channel can t overwrite 0x16001 Backplane Timer registed 0x16002 Backplane Timer not registed PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 430 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 Functions Models XP 8000 XP 8000 Atom XP 8000 CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xx VP 25W VP 23W CE6 x pac_GetModuleNam Y Y Y Y Y Y Y Y Y Y e pac GetRotaryID Y Y Y Y Y Y Y Y Y Y pac_GetSerialNumb Y Y Y Y Y Y Y Y Y Y er pac GetSDKVersion Y Y Y Y Y Y Y Y Y pac ChangeSlot Y Y Y Y Y Y Y pac CheckSDKVersio Y Y Y Y Y Y Y Y Y Y n pac ModuleExists Y Y Y Y Y Y Y pac GetOSVersion Y Y Y Y Y Y Pac
46. E mail service icpdas com WP 8000 ViewPAC WinCE 187K module 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 87 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 0 Last Revised January 2013 Page 163 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Although user can use 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 I 811xW 1 814xW serises modules XPAC Any serial devices connected with COM port Any serial devices connected with COM port er Ec E a B COM 1 7000 or b ES 1 87K4 5 8 9 cle len PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 164 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 COM 1 COM2 COMS of WP 5000 series In addition of COM1 COM2 COM3 all of the functions can be used to communicate wi
47. G XPAC PC CDe Standard API User Manual Windows XP Based eVC amp NET Version 1 1 0 January 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 quick response Email service icpdas com PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Contents T NITEN 3 About this 11 TGetting Started IH
48. ICP DAS Co Ltd All Rights Reserved D lt 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 int TotalCh float fValue Parameters hPort in The serial port HANDLE opened by uart OpenY 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 323 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 BOOL iRet pac_ReadModuleSafeValueAO hPort iSlot iChannel iAO_TotalCh amp fValue uart_Close hPort CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1
49. 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 IO ReadDO PAC IO ReadDO MF reads the DO value of the DO module pac ReadDl pac ReadDI MF PAC IO ReadDI PAC IO ReadDI MF reads the DI value of the DI module pac ReadDlO pac ReadDIO MF PAC IO ReadDIO PAC IO ReadDIO MF reads the DI and the DO values of the DIO module pac ReadDlLatch PAC 10 ReadDILatch reads the DI latch value of the DI module pac ClearDILatch PAC IO ClearDILatch clears the latch value of the DI module pac ReadDlOLatch PAC 10 ReadDIOLatch reads the latch values of the DI and DO channels of the DIO module pac_ClearDIOLatch PAC 10 ClearDIOLatch clears the latch values of DI and DO channels of the DIO module pac_ReadDICNT pac_ReadDICNT_MF PAC IO ReadDICNT PAC IO ReadDICNT MF reads the counts of the DI channels of the DI module pac ClearDICNT pac ClearDICNT MF PAC PAC IO ClearDICNT IO ClearDICNT MF clears the counter value of the DI channel of the DI module pac WriteAO pac WriteAO MF PAC 10 WriteAO PAC IO WriteAO MF writes the AO value to the AO modules pac ReadAO reads the AO value of the AO module PAC IO ReadAO pac ReadAI PAC 10 ReadAl reads the engineering mode Al value of the A
50. Last Revised January 2013 Page 440 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 Y Y Y Y Y Y Y Y pac GetPWMDuty Y Y Y Y Y Y Y Y pac SetPWMFrequency Y Y Y Y Y Y Y Y pac GetPWMFrequency Y Y Y Y Y Y Y Y pac SetPWMMode Y Y Y Y Y Y Y Y pac GetPWMMode Y Y Y Y Y Y Y Y pac_SetPWMDITriggerConfig Y Y Y Y Y Y Y Y pac_GetPWMDITriggerConfig Y Y Y Y Y Y Y Y pac_SetPWMsStart Y Y Y Y Y Y Y Y pac_SetPWMSynChannel Y Y Y Y Y Y Y Y pac_GetPWMSynChannel Y Y Y Y Y Y Y Y pac_SyncPWMsStart Y Y Y Y Y Y Y Y pac_SavePWMConfig Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 441 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_GetPWMDIOStatus Y Y Y Y Y Y Y Y pac SetPWMPulseCount Y Y Y Y Y Y Y Y pac GetPWMPulseCount Y Y Y Y Y Y Y Y Backplane Functions Functions MModels XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac GetBPTimerTimeTick ms Y N N Y Y Y Y pac GetBPTimerTimeTick us pac SetBPTimer pac SetBPTimerOut pac SetBPTimerlnterruptPriority lt lt lt lt lt zizizzz zizizzz EJ lt lt
51. Ltd All Rights Reserved D lt 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 module is remote please use the macro 255 enStatus out 1 the host watchdog is enabled 0 the host watchdog is disabled watTimeout out The unit of return value is 100ms ifWDT_Overwrite only for i 8k out 1 the host watchdog does overwrite 0 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 0 Last Revised January 2013 Page 338 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 0 short sStatus 0 unsigned long ulWDTtime 0 int iOverwrite 0 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 iOverwrite 0 hPort PACNET UART Open PACNET IO GetModuleWDTConfig hPort iSlot ref sStatus ref ulWDTtime ref iOverwrite PACNET UART Clo
52. MEMORY BASE 6 PAC ERR READ FAIL PAC ERR MEMORY BASE 7 UART PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW PAC_ERR_UART_BASE 9 PAC ERR IO DO CANNOT OVERWRITE PAC ERR IO BASE 10 PAC ERR IO AO CANNOT PAC ERR IO BASE 11 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 465 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 WinPacSDKlib C EXE ARM The C 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 o Project Refer to WinPacNet dll PC WinPAC PAC Standar
53. PACNET UART Open byte iSlot 1 bool iRet PACNET PWM SavePWM Config hPort iSlot PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 381 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro PAC REMOTE 0 255 pwmbBitArr out where array 0 corresponds to PWM channel 0 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 0 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 0 Last Revised January 2013 Page 382 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D4 E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the re
54. 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 Consequently 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 bFlag is been reserved and a new API function has been added pac EnableLEDs int pin bool bFlag PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 445 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 seri
55. Page 70 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 1 12 pac_BuzzerBeep This function generates simple tones on the speaker Syntax C void pac BuzzerBeep WORD count DWORD milliseconds Parameters count in Specifies the number of beeps milliseconds in Specifies the duration of the sound measured in milliseconds Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 71 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C pac BuzzerBeep 1 100 CH Beep 1 time for 1 second PACNET Sys Buzzer BuzzerBeep 1 1000 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 72 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 13 pac_GetBuzzerFreqDuty This function retrieves the frequency value and duty cycle value of the buzzer Syntax C void pac_GetBuzzerFreqDuty int freq int duty Parameters freq out The frequency of the sound ranging from 37 to 32767 hertz duty out The duty cycle of the sound Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 73 Examples
56. 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 296 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 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 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 frequency module iOverflow out The pointer to the counter overflow that is read back from the counter frequency module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 297 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 Examp
57. WriteAO pac WriteAO Functions and available modules are as following Since November 1 2012 pac Write AO pac WriteAO MF I 87024W CW DW RW 1 87024 I 87026PW I 87028CW UW 87022 87026 I 7021 1 7021P l 7022 l 7024 l 8024R PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 450 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 5 Add Misc API function for PACSDK The new PACSDK dll provides 2 miscellaneous API functions below pac GetCurrentDirectory pac GetCurrentDirectoryW 6 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 0x2000 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 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 0 0x80000 512KB of SRAM is available for the use by the user PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 451 Copyright 2013
58. XPacSDK dll DCON PC dll PACSDK PWM 3dll Target device NET CF DLL files XpacNet dll DCON PC DotNet dll PACNET dIl Benefits of the unified SDK include Easily migrates custom PC programs to the XPAC series Easily migrates custom XPAC programs to the PC A suite of PACSDK APIs is almost same as the previous SDK XPACSDK dll and DCON PC adll but there are some modifications and updates Refer to the Appendix C for more details PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 16 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 2 Copying the PACSDK Users just need through a simple action that copies the PACSDK dll to a specified folder and then they can use the PACSDK library to develop the applications for the XPAC series and PC To download and copy the new PACSDK to a specified folder 1 Get the latest version of PACSDK library The latest version of the installation package from FTP site listed as following FTP http ftp icpdas com pub cd xp 8000 pacsdk driver http ftp icodas com pub cd xpac atom pacsdk driver 2 Copy the PACSDK dll to the Windows system directory and copy the corresponding PACSDK library to the application folder for reference The default location of Windows system directory for XPAC and PC is listed as below XPAC series C WINDOWS Windows XP on PC C WINDOWS System32 Windows 7 on PC Windows 8 on PC
59. 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 00M result string str PACNET MISC WideString result PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 417 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 418 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 11 3 pac_AnsiToWideString 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 receives the converted Unicode string Return Value This function has does not return a value PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved DX 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 messag
60. 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 00M result SOOM ask the This function relates to uart_Send uart_Recv uart_SendCmd PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 193 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 this 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 y 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 0 Last Revised January 2013 Page 194 Copyright 2013 ICP DAS Co Ltd All Rights Reserv
61. err FALSE pac_GetErrorMessage pac_GetLastError strErr printf Read SRAM failure The error code is x n pac_GetLastError printf 96s strErr return 0 printf s n buffer PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 408 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 printf s n buffer return 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 409 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com CH 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 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 0 is
62. 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 247 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 intiDO TotalCh int iLatchType DWORD IDI Latch Value DWORD IDO Latch Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 248 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDI TotalCh in The total number of the DI channels of the DIO module iDO 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 0 latched low status IDI Latch Value out The pointer to the DI latch value read back IDO Lat
63. 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 0 Last Revised January 2013 Page 423 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C int counter 0 char buf 10 bFlag true while bFlag pac_DoEvents sprintf buf 96d counter SetDlgltemText IDC EDIT1 buf counter PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 424 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 11 6 pac_GetCurrentDirectory This function retrieves the current directory of the 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 informati
64. http www icpdas 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 0 Last Revised January 2013 Page 208 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 ReadDI 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 AIO or Counters but are equipped with DIO channels Such as the I 87005W 1 87016W 1 87082W 1 7016 1 7088 etc The instructions of two fucntions i e pac WriteDO and pac WriteDO 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 v
65. 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 chlndex 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel mode out 0 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 0 Last Revised January 2013 Page 366 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 long mode uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong mode PACNET UART Close hPort BOOL iRet pac_GetPWMMode hPort iSlot iChannel amp mode bool iRet PACNET PWM GetPWMMode hPort iSlot iChannel ref mode PAC Standard
66. 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 0 iSlot iChannel iAO_TotalCh fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 265 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteAO Vf 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 ichannel iAO_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 the macro PAC REMOTE 0 255 which range is from 0 to 255 2 The comparison table of pac WriteAO pac WriteAO MF Functions and available modules are as following Since November 1 2012 pac Write AO pac WriteAO MF I 87024W CW DW RW 1 87024 Il 87026PW I 87028CW UW I 87022 87026 7021 7021P l 7022 l 7024 8024R PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 266
67. is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 245 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 8 ClearDILatch This function clears the latch value of the DI module Syntax C BOOL pac_ClearDILatch 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 iSlot in The slot in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 246 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac ClearDILatch hPort iSlot uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 BOOL iRet pac ClearDILatch O iSlot CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 bool iRet PACNET IO ClearDILatch hPort iSlot PACNET UART Close hPort Remarks The function can support
68. module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel duty in The duty cycle value to write to the PWM module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 356 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 float fValue 1 23 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 float fValue 1 23 PACNET UART Close hPort BOOL iRet pac_SetPWMDuty hPort iSlot iChannel fValue bool iRet PACNET PWM SetPWMDuty hPort iSlot iChannel fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 357 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 2 pac GetPWMbDuty 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
69. 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 0 Last Revised January 2013 Page 311 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac WriteModulePowerOnValueDO Example 1 f 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 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 uart Close hPort BOOL ret pac WriteModulePowerOnValueDO hPort PAC REMOTE IO 1 BOOL ret pac WriteModulePowerOnValueDO hPort 1 total channel do value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 312 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C pac WriteModulePowerOnValueDO MF Example 1 f 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 f the module is 87k local HANDLE hPort hPort
70. 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 0 Last Revised January 2013 Page 138 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret ret pac_RegCreateKey TEXT HKEY_USERS myKey CH bool ret ret PACNET PAC_Reg RegCreateKey HKEY_CURRENT_USER myKey PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 139 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 LPCSTR 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 0 Last Revised January 2013 Page 140 Copyright 2013 ICP DAS
71. port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDO 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 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 0 Last Revised January 2013 Page 230 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDO 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 hPort slot total channel amp do_value uart_Close hPort Example 2 f the module is 8k local BYTE slot 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 slot total channel amp do value uart Close hPort PAC Standard API Manual v1 1 0 Last Revised January
72. 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 UART Open int total channel 8 uintdo 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 0 Last Revised January 2013 Page 304 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO_MF Example 1 f 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 1O 1 total channel do value PACNET UART Close hPort Example 2 f 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 pac WriteModuleSafeValueDO MrF 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 255 which range is from 0 to 255 PAC Standard API
73. the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 short Status 0 BOOL iRet pac_SyncPWMsStart hPort iSlot Status uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 short Status 0 bool iRet PACNET PWM SyncPWMStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 379 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 380 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac_SavePWMConfig hPort iSlot uart_Close hPort CH IntPtr hPort hPort
74. the version number of the current PACSDK dll PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 105 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 PAC MEM SRAM 1 PAC MEM EEPROM Return Value The return value specifies the memory size PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 106 Examples C DWORD mem size mem_size pac_GetMemorySize PAC_MEM_SRAM CH uint mem size int PAC MEM SRAM 0 int PAC MEM EEPROM 1 mem size PACNET Memory GetMemorySize PAC MEM SRAM Console WriteLine The SRAM size is mem_size ToString mem size PACNET Memory GetMemorySize PAC MEM EEPROM Console WriteLine The EEPROM size is mem_size ToString Console ReadLine The example displays the following output to the console The SRAM size is 524288 The EEPROM size is 16384 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 107 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 2 pac ReadMemory This function retrieves data from the sp
75. 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 0 Last Revised January 2013 Page 313 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModulePowerOnValueDO Example 1 If the module is remote IntPtr 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 WriteModulePowerOnValueDO hPort PACNET IO REMOTE 1 total channel do value PACNET UART Close hPort Example 2 f 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 hPort 1 total channel do value PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 314 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com CH pac WriteModulePowerOnValueDO MF Example 1 f the module is remote IntPtr 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 WriteModulePowerOnValueDO MF hPort PACNET IO REMOTE_10 1 total channel do valu
76. 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 O Ox1FFF address of the EEPROM or the 0 Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 113 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 enable the writing for the EEPROM False To disable the writing for the EEPROM Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 114 Examples C define LENGTH 2 int ret DWORD address 0 BYTE Buffer LENGTH Buffer 0 OxAB Buffer 1 OxCD Int PAC_MEM_EEPROM 1 pac_EnableEEPROM true ret pac_WriteMemory address Buffer LENGTH PAC_MEM_EEPROM pac_EnableEEPROM false CH Demonstrate how to store the data in the EEPROM uin
77. 0 Last Revised January 2013 Page 292 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 iChannelz0 DWORD ICounter_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 0 DWORD ICounter_ Value BOOL iRet pac ReadCNT hPort iSlot iChannel amp lCounter_ Value BOOL iRet pac ReadCNT O iSlot iChannel amp lCounter Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 293 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 uint ICounter Value PACNET UART Close hPort Remarks bool iRet PACNET IO ReadCNT hPort iSlot iChannel ref ICounter Value 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 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 294 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
78. 1 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 0 Last Revised January 2013 Page 88 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something return true void ClntrDlg OnButton1 void CIntrDlg OnButton2 Remarks for XPAC series only Default trigger type is level trigger For XP 8000 series only support level trigger type pac RegisterSlotInterrupt slot slot callback proc 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 pac EnableSlotInterrupt slot true enable slot interrupt pac EnableSlotInterrupt slot false disable slot interrupt pac UnregisterSlotInterrupt slot unregister slot interrupt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 89 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 2 2 pac_UnregisterSlotinterrupt This function unregisters slot interru
79. 1 123 125 127 129 134 136 138 140 142 144 146 148 150 152 154 156 158 160 169 173 175 177 179 182 2 6 7 uart_SendCmdExt 2 6 8 uart_SetTimeOut 2 6 9 uart_EnableCheckSum 2 6 10 uart_SetTerminator 2 6 11 uart_BinSend 2 6 12 uart_BinRecv 2 6 13 uart_BinSendCmd 2 6 14 uart_GetLineStatus 2 6 15 uart_GetDataSize 2 6 16 uart_SetLineStatus 2 7 IO API ceccccccsseecceseecnenceccnsceccsseeeeeeeees 2 7 1 pac GetBit 2 7 2 pac WriteDO pac WriteDO MF 2 7 3 pac WriteDOBit 2 7 4 pac ReadDO pac ReadDO MF 2 7 5 pac ReadDl pac ReadDI MF 2 7 6 pac ReadDlO pac ReadDIO MF 2 7 7 pac_ReadDILatch 2 7 8 pac ClearDlILatch 2 7 9 pac ReadDlOLatch 2 7 10 pac ClearDlOLatch 2 7 11 pac ReadDICNT pac ReadDICNT MF 2 7 12 pac ClearDICNT pac ClearDICNT MF 2 7 13 pac WriteAO pac WriteAO MF 2 7 14 pac ReadAO 2 7 15 pac_ReadAl 2 7 16 pac ReadAIHex PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 6 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 184 187 190 192 194 196 198 201 203 204 217 219 225 229 233 237 242 246 248 252 254 259 263 267 271 275 2 7 17 pac ReadAIAIIExt 2 7 18 pac ReadAIAII 2 7 19 pac ReadAIAIIHexExt 2 7 20 pac ReadAIAllHex 2 7 21 pac ReadCNT 2 7 22 pac ClearCNT 2 7 23 pac
80. 1 CED ss 474 F 3 XP 8141 Atom CEG niii 475 F 4 XP 8341 Atom CE6 XP 8741 AtOM CEG e eeeeeeee ee eene nennen nene unen tete 476 FS boda e 477 WP 84x LUC a ek ER 478 FZ WP 5141 WP 5141 OD 479 E 480 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 10 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com About this Guide This manual is intended for software developers who want to integrate XPAC PC functionality into their applications What Models and PC OS are covered in this Manual The following PAC models and PC OS are covered in this manual XPAC family for x86 platform series XP 8041 Windows Embedded Standard 2009 XPAC with 0 I O slot XP 8341 Windows Embedded Standard 2009 XPAC with 3 I O slots XP 8741 Windows Embedded Standard 2009 XPAC with 7 I O slots XP 8141 Atom Windows Embedded Standard 2009 XPAC with 1 1 0 slot XP 8341 Atom Windows Embedded Standard 2009 XPAC with 3 I O slots XP 8741 Atom Windows Embedded Standard 2009 XPAC with 7 I O slots Supported Windows OS for PC Windows XP Windows 7 Windows 8 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 11 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Related Information For additional informat
81. 1000001 if your application should use newer than version 1 0 0 1 if your application should use newer than version 1 0 0 1 If the version of the currently used PACSDK dll is not 1 0 0 1 or earlier PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 58 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 1 7 pac ModuleExists This functions specifies whether the local module exist in the XPAC or not Syntax C BOOL pac_ModuleExists HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open Because the API only uses for local modules this parameter must be 0 Slot in The slot in which module is to check exists or not 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 0 Last Revised January 2013 Page 59 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 5 if bExist MessageBox The module exist else MessageBox The module unexist CH Check if a module exists in the slot 5 of the XPAC bool bExist IntPtr hPort PACNET UART Op
82. 13 ICP DAS Co Ltd All Rights Reserved D lt 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 Ek C for pac WriteAO MF BOOL pac WriteAO MF HANDLE hPort int slot int iChannel intiAO TotalCh float fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 263 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that is written thee AO value to 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 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 0 Last Revised January 2013 Page 264 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C pac_WriteAO Example 1 f the module
83. 13 Page 100 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 101 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C HANDLE hintr BOOL bExit false BYTE slot 0 DWORD Thread PVOID pContext i while bExit WaitForSingleObject hintr INFINITE do something pac_InterruptDone slot pac EnableSlotInterrupt slot false pac SetSlotInterruptEvent slot NULL CloseHandle pac GetSlotInterruptEvent slot return 0 void CInterruptDlg OnButton1 bExit true pac Interruptlnitialize slot pac EnableSlotInterrupt slot true hintr pac GetSlotInterruptEvent slot CreateThread NULL O INTP Thread amp slot O NULL PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 102 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 3 Memory Access API The memory access functions provide the memory management that may be used for reading writing EEPROM or SRAM or mounting um
84. 2 10 1 2 10 2 2 10 3 2 10 4 2 11 Misc API pac SetPWMFrequency pac GetPWMFrequency pac SetPWMMode pac GetPWMMode pac SetPWMDlITriggerConfig pac GetPWMDlITriggerConfig pac SetPWMsStart pac SetPWMSynChannel pac GetPWMsSynChannel pac SyncPWMStart pac SavePWMConfig pac GetPWMDIOStatus pac SetPWMPulseCount pac GetPWMPulseCount pac GetBPTimerTimeTick ms pac GetBPTimerTimeTick us pac SetBPTimer pac SetBPTimerOut pac SetBPTimerlnterruptPriority pac KillBPTimer pac GetLastError pac SetLastError pac GetErrorMessage pac ClearLastError PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Page 8 gt lt E mail service icpdas com 360 362 364 366 368 370 372 374 376 378 380 382 384 386 391 392 393 395 397 399 403 405 407 412 2 11 1 AnsiString 415 2 11 2 WideString 417 2 11 3 pac_AnsiToWideString 419 2 11 4 pac_WideToAnsiString pac_WideStringToAnsi _ 421 2 11 5 pac_DoEvent pac_DoEvents 423 2 11 6 pac_GetCurrentDirectory 425 2 11 7 pac_GetCurrentDirectoryW 427 Appendix A System Error Codes ccssscccsssseccsssscccssecccssseccesssccscsseseneseees 429 Appendix B API Comparison e eeee ee eene ee eene enne 431 Appendix C What s New in PACSDK e e eese ee eene ee ee
85. 7 WP 5141 WP 5141 OD H La ww ua eI E b L J COM1 COM2 COM3 RS 232 RS 485 RS 232 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 479 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 8 VP 2xW1 COMO COM3 COM Slot 0 2 RS 232 RS 485 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 480 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com
86. 8 uint IDI Value 0 IntPtr hPort hPort PACNET UART Open bit PACNET IO GetBit iDI TotalCh index PACNET UART Close hPort Remarks The function is used the same as v amp 1 index BOOL iRet pac ReadDl hPort iSlot iDI TotalCh amp IDI Value bool iRet PACNET IO ReadDl hPort iSlot iDI TotalCh ref IDI Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 218 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 Last Revised January 2013 Page 219 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro 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 corres
87. 8112 8114 8142 1 8144 use MSA B english pdf Use I 87K series modules Only use COMO to communicate with I 87K series modules Please refer to Sec 8 UART API PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 172 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 173 Examples C BOOL ret HANDLE hOpen hOpen uart_Open COM1 9600 N 8 1 ret uart_Close hOpen CH 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 0 Last Revised January 2013 Page 174 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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
88. 8KB for users 0x2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only 0 Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system lpBuffer 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 0 PAC MEM SRAM 1 PAC MEM EEPROM 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 0 Last Revised January 2013 Page 112 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C define LENGTH 2 bool ret DWORD address 0 BYTE Buffer LENGTH Buffer 0 10 Buffer 1 20 ret pac WriteMemory address Buffer LENGTH PAC MEM SRAM CH Demonstrate how to store data 10 and 20 in the address 0 1 of SRAM uint address 0 byte Buffer new byte 2 10 20 int PAC MEM SRAM 0 PACNET Memory WriteMemory address Buffer 2 PAC MEM SRAM Remarks If an older program is coded to
89. 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 0 Last Revised January 2013 Page 456 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 457 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 C program Modify the code for using XPAC series devices using XPacNET to using PACNET using XPacNet Changed as using PACNET Modify the code for using XPAC series devices using WinPacNet to using
90. AS Co Ltd All Rights Reserved gt lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDI TotalCh in The total channels of the DI module IDI Value out The pointer to DI value to 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 0 Last Revised January 2013 Page 234 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDI Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 2 int iDI_TotalCh 8 DWORD Value BOOL iRet pac ReadDl hPort iSlot iDI TotalCh amp IDI Value uart Close hPort Example 2 f the module is 8k local BYTE iSlot 2 int iDI_TotalCh 8 DWORD 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 iDI_TotalCh 8 DWORD IDI Value BOOL iRet pac_ReadDI_MF hPort iSlot iDI TotalCh amp IDI Val
91. Basic gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project Hew Project Project types E Templates 2 NET Framework 3 5 Visual Visual Studio installed templates E Other Languages IMPERIA B Visual Besic Windows Forms Application Chs Library e az WPF Application Pg WPF Browser Application e EN Sari Device A Console Application Empty Project i Office el Windows Service Ye WPF Custom Control Library Database 55 WPF User Control Library 5 Windows Forms Control Library Reporting Test My Templates WCF see eee Workflow jJSearch Online Templates Visual C Other Project Types Test Projects A project for creating an application with a Windows user interface NET Framework 3 5 Name SDKInformation Location DADoing Solution Name SDK Information Create directory for solution PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 31 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add a button control to the Windows form 1 Open the form 2 Inthe Toolbox click the Button control and drag it to your form 3 Double click the button on the form to create a Click event Toolbox vb Design Start Page X Office Ribbon Controls r d
92. C series device must work with PACSDK dll VC Project Link gt C EXE ARM PACSDK lib The C 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 Project Link PACNET dll PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 470 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 ftp icpdas com pub cd winpac napdos wp 8x4x ceb50 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 ftp 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 0 Last Revised January 2013 Page 471 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Appendix F Comparison of Defined Slots and COM Ports Each PAC has its own definition and corresponding communication ports and s
93. CNT_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iD TotalCh 8 DWORD ICounter_ Value BOOL iRet pac ReadDICNT hPort iSlot iChannel iDI_ TotalCh amp lCounter Value uart_Close hPort C pac_ReadDICNT 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 iDI_TotalCh ref ICounter Value PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 257 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 iDl_TotalCh 8 uint ICounter Value PACNET UART Close hPort Remarks bool iRet PACNET IO ReadDICNT hPort iSlot iChannel iDI_TotalCh ref ICounter Value 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 1O 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 258 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 12 pac Clea
94. C_WDT_OS Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 121 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C pac DisableWatchDog PAC WDT OS CH Demonstrate how to disable the watchdog PACNET Sys WDT EnableWatchDog 1 10 First enable the OS watchdog Console WriteLine Press any key to disable the watchdog in 10 Seconds Console ReadLine PACNET Sys WDT DisableWatchDog 1 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 122 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 3 pac RefreshWatchDog This function refreshes the watchdog Syntax C void pac_RefreshWatchDog int wdt Parameters wat in Specifies the Watchdog type 0 Hardware watchdog PAC_WDT_HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PAC_WDT_OS Return Value This function does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 123 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C pac RefreshWatchDog PAC WDT OS CH Demonstrate how to refresh the watchdog PACNET Sys WDT EnableWatchDog 1 10 First enable the OS watchdog
95. Channel 2 short mode PACNET UART Close hPort BOOL iRet pac_GetPWMDITriggerConfig hPort iSlot iChannel amp mode bool iRet PACNET PWM GetPWMDITriggerConfig hPort iSlot iChannel ref mode PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 371 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com 2 8 9 SetPWMsStart This function sets the status of the PWM output port Syntax C bool pac_SetPWMStart 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 module is remote please use the macro 0 255 enStatus in bit O corresponds to PWM channel 0 and bit 1 corresponds to PWM channel 1 etc When the bit is O 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 0 Last Revised January 2013 Page 372 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 s
96. D lt E mail service icpdas com 2 Using PACNET dll PACNET dll is a net Compact framework SDK and PACNET dll is not only used for C program but also used for VB net program gt PACNET II the execution file should be put in the same directory of the PACNET dIl The latest version of this library is located at CD root Xpac Atom SDK PACSDK Driver DOTNET in the companion CD http ftp icpdas com pub cd xpac atom sdk pacsdk driver dotnet Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Tool Test Window Help New Gy B jet E Web Site shiita tN 3 Fib CHiN Project From Existing Code Save All Chl Shits Recent Files Recent Projects Exit PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 27 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 Inthe Project Type column choose Visual C gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project New Project Project types Templates NET Framework 30 v Visual C Visual Studio installed templates Windows Web Windows Forms Application abs Library E Device ra WPF Application Fg WPF Browser Application I bus Gli Console Application Empty Project Reporting ar Windows Service S WPF Cust
97. D lt 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 version number This function does not support all versions of XPACSDK Syntax C BOOL pac_CheckSDKVersion DWORD version Parameters version in The version number of the PACSDK If the version number is 1 0 0 1 or previous 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 0 Last Revised January 2013 Page 57 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Added this API in the begin of your application BOOL bVersion bVersion pac CheckSDKVersion 0x01000001 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 if bVersion display some warning and close the application Console ReadLine the output to the console is as below The PACSDK dll version is wrong Console WriteLine The PACSDK dll version is wrong bVersion PACNET Sys CheckSDKVersion 0x0
98. 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 uart_Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 hPort PACNET UART Open PACNET UART Close hPort lastOutput pac_GetModuleLastOutputSource hPort iSlot int lastOutput PACNET IO GetModuleLastOutputSource hPort iSlot PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 333 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 334 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro PAC R
99. DWORD do_ value uart_Close hPort BOOL ret pac_ReadModuleSafeValueDO hPort slot total channel amp do value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 307 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C pac_ReadModuleSafeValueDO_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 ReadModuleSafeValueDO MF hPort slot total channel amp do value uart Close hPort 6 pac ReadModuleSafeValueDO 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_ReadModuleSafeValueDO hPort slot total channel ref do_value PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 308 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModuleSafeValueDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do_value do_value PACNET UART Close hPort Remarks bool ret PACNET IO pac_ReadModuleSafeValueDO_MEF hPort slot total channel ref The function can support for Local or Remote When the module is local the second Parameter
100. EMOTE 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 0 Last Revised January 2013 Page 335 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 20 bool bStatus 0 hPort uart_Open bStatus pac_GetModuleWDTStatus hPort iSlot uart_Close hPort CH If 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 hPort Remarks 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 336 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 337 Copyright 2013 ICP DAS Co
101. EXISTS PAC_ERR_BASE 7 PAC ERR INVALID SLOT NUMBER PAC ERR BASE 8 nterrupt 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 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 0 Last Revised January 2013 Page 463 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 464 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 WRITE FAIL PAC ERR
102. 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 0 Last Revised January 2013 Page 175 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0x0D The terminate characters is OxOD Refer to uart_SetTerminator function to cha
103. 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 CH bool ret IntPtr hPort string buf hPort PACNET UART Open COM2 9600 N 8 1 PACNET UART Close hPort Remarks ret PACNET UART Recv hPort WinPAC AnsiString buf 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 0 Last Revised January 2013 Page 183 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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_SendCmdExt HANDLE hPort LPCSTR cmd DWORD out_Len LPSTR szResult DWORD in_Len PAC Standard API Manual v1 1 0 Last Revised January 2013 Page
104. GetCPUVersion Y Y Y Y Y Y Pac EnableLEDs Y Y pac GetModuleType Y Y pac BuzzerBeep Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 431 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_GetBuzzerFreqD Y Y T uty pac SetBuzzerFreqD Y Y uty pac StopBuzzer pac GetDIPSwitch pac GetSlotCount pac GetBackplanelD pac GetBatteryLevel pac EnableRetrigger pac GetMacAddress z lt lt lt lt x lt lt x pac_ReBoot z lt lt x Pac_EnableLED n lt lt x lt x lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt pac_BackwardComp Z atible pac GetEbootVersio z d n pac_GetComMappin z 8 pac RegistryHotPlug Beta testing pac UnregistryHotPl ug Beta testing PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 432 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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_RegisterSlotInterrupt Y Y Y Y Y Y Y
105. HANDLE port int slot short chlndex 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel mode in 0 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 0 Last Revised January 2013 Page 364 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannelz2 long mode 0 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong mode 0 PACNET UART Close hPort iRet pac_SetPWMMode hPort iSlot iChannel mode bool iRet PACNET PWM SetPWMMode hPort iSlot iChannel mode PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 365 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service
106. I BPTimer 2 10 Error Handling API ErrHandling 2 11 Misc API MISC PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 455 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 adll 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 WDT PowerOn Safe Value API functions for pure DIO modules is placed in PACNET PAC 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 modifications 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 class Add Misc
107. ICP DAS Co Ltd All Rights Reserved D lt 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 Hinclude 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 include 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 0 Last Revised January 2013 Page 452 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com The original flowchart for a C program that is calling the previous SDK is illustrated below Project A Tee C EXE ARM WinPacSDK 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 fu
108. Latch Value uint IDO Latch Value byte cDI Latch BitValue byte cDO Latch BitValue IDI Latch Value ref IDO Latch Value PACNET UART Close hPort Remarks bool iRet PACNET IO ReadDlOLatch hPort iSlot iDI TotalCh iDO TotalCh iLatchType ref 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 251 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 10 pac_ClearDIOLatch This function clears the latch values of DI and DO channels of the DIO module Syntax C BOOL pac_ClearDIOLatch 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 iSlot in The slot in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 252 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Exampl
109. Manual v1 1 0 Last Revised January 2013 Page 305 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 kh C for pac ReadModuleSafeValueDO MF BOOL pac ReadModuleSafeValueDO MF HANDLE hPort int slot int iDO TotalCh unsigned long IValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 306 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 module is remote please use the macro PAC REMOTE 0 255 iChannel in The total number of DO channels of the DO modules IValue 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
110. Manual v1 1 0 Last Revised January 2013 Page 49 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 3 pac GetSerialNumber This function retrieves the serial number of the XPAC hardware ID Syntax C void pac GetSerialNumber LPSTR SerialNumber Parameters SerialNumber out The serial number of the XPAC hardware ID Return Value This function does not return a value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 50 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char SN 32 pac GetSerialNumber SN CH string SN SN PACNET Sys GetSerialNumber Console WriteLine The Serial Number is SN Console ReadLine The example displays the following output to the console The Serial Number is 01 38 11 79 14 00 00 2F Remarks If the retrieved value is null means the function executes failure or the device is not valid product PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 51 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 ret
111. O 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 0 Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Last Revised January 2013 Page 211 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_GetModuleWDTInterruptStatus M Y pac SetModuleWDTlInterruptStatu S PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 212 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PAC IO Functions The following functions are used to retrieve or set the I0 modules PACSDK Functions pac GetBit PACNET Functions PAC IO GetBit Description retrieves the value which in specific bit pac_WriteDO pac_WriteDO_MF PAC IO WriteDO PAC IO WriteDO MF writes the DO values to DO modules pac WriteDOBit PAC
112. PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 436 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_RegSetDWORD Y Y Y Y Y Y Y Y UART Functions Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx m lt lt lt m lt lt lt uart_Open uart_Close uart_SendExt uart_Send uart_RecvExt uart_Recv uart_SendCmdExt uart_SetTimeOut uart_EnableCheckSum uart_SetTerminator uart_BinSend uart_BinRecv lt lt lt lt lt lt lt XR XR lt lt lt lt lt lt lt XR lt lt lt lt lt lt lt lt lt XR XR X lt lt lt lt lt lt lt XR XR X lt lt lt lt lt lt lt lt lt XR XR LK lt lt lt lt lt lt lt lt lt XR XR LX lt lt lt lt lt lt lt lt lt XR XR X lt lt lt lt lt lt lt lt lt XR uart_BinSendCmd PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 437 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com uart_GetLineStatus Y Y uart_GetDataSize Y Y uart_SetLineStatus Y Y PAC Functions Functions Models pac_GetBit XP 8000 CE6
113. 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 0 Last Revised January 2013 Page 458 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com With the previous NETCF library WinPacNet dll or XPacNet dll the flowchart was as follows Project A het EXE WinPAC Wi inPacNet dll WiinPacSDK 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 which must be run with XpacNet dll and XPacSDK CE dll With the new NETCF library PACNET dll and the flowchart becomes PACSDK dll ARM Project Code
114. Port int slot int iDO_TotalCh DWORD lValue C for pac_WriteModuleSafeValueDO_MF BOOL pac WriteModuleSafeValueDO MF HANDLE hPort int slot int iDO TotalCh DWORD IValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 300 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDO TotalCh in The total number of DO channels of the DO modules iValue 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 0 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 0 Last Revised January 2013 Page 301 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteModuleSafeValueDO Example 1 f 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_WriteModuleSa
115. Ptr hPort string buf buf abcd hPort PACNET UART Open COM2 9600 N 8 1 PACNET UART Close hPort Remarks ret PACNET UART Send hPort WinPAC AnsiString buf 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 Check sum is disabled The buf are five bytes ABCD 0x0 This function will send five bytes ABCD OxOD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 178 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 6 5 uart RecvExt This function receives a string OxOD 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 OxOD 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 point
116. R 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret ret pac_RegSetDWORD TEXT HKEY_USERS myKey value 40 CH bool ret ret WinPAC RegSetDWORD HKEY_USERS myKey value 40 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 161 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 I 811xW 1 814xW series 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 87 XPAC COMI For I 87K module in I O slot PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 162 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt
117. ReadCNTOverflow 2 7 24 pac WriteModuleSafeValueDO pac WriteModuleSafeValueDO MF 2 7 25 pac ReadModuleSafeValueDO pac ReadModuleSafeValueDO MF 279 283 285 289 292 295 297 300 306 2 7 26 pac WriteModulePowerOnValueDO pac WriteModulePowerOnValueDO MF310 2 7 27 pac ReadModulePowerOnValueDO pac ReadModulePowerOnValueDO MF 316 2 7 28 pac WriteModuleSafeValueAO 2 7 29 pac ReadModuleSafeValueAO 2 7 30 pac WriteModulePowerOnValueAO 2 7 31 pac ReadModulePowerOnValueAO 2 7 32 pac GetModuleLastOutputSource 2 7 33 pac GetModuleWDTStatus 2 7 34 pac GetModuleWDTConfig 2 7 35 pac SetModuleWDTConfig 2 7 36 pac ResetModuleWDT 2 7 37 pac RefreshModuleWDT 2 7 38 pac InitModuleWDTInterrupt 2 7 39 pac GetModuleWDTlInterruptStatus 2 7 40 pac SetModuleWDTlnterruptStatus 2 8 PWM API cesses eene eene nennt nnn 2 8 1 pac SetPWMbDuty 2 8 2 pac GetPWMbDuty PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 7 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 320 323 326 329 332 335 337 340 343 345 347 349 351 356 358 2 8 3 2 8 4 2 8 5 2 8 6 2 8 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 2 8 16 2 9 Backplane Timer API 2 9 1 2 9 2 2 9 3 2 9 4 2 9 5 2 9 6 2 10 Error Handling API
118. 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 0 Last Revised January 2013 Page 286 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iValue 8 int ichannelnumber 0 uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int ichannelnumberz0 int iValue 8 CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int ichannelnumber 0 int iValue 8 PACNET UART Close hPort BOOL iRet pac ReadAIAIIHexExt hPort iSlot iValue 8 amp ichannelnumber BOOL iRet pac_ReadAIAllHexExt 0 iSlot iValue 8 amp ichannelnumber bool iRet PACNET IO ReadAIAllHex hPort iSlot iValue 8 ref ichannelnumber PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 287 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Pa
119. 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 0 Last Revised January 2013 Page 181 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 OxOD 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 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 0 Calling pac GetLastError function will get an error code pac ERR uart READ TIMEOUT PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 182 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com
120. TotalCh As Integer ByVal IDO Value As Ulnteger As Boolean I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I i End Function I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I Private Sub Button1_Click ByVal sender As System Object ByVal e As System EventArgs Handles Button1 Click pac_WriteDO CType 1 IntPtr 1 16 amp Hff End Sub End Class PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 33 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 Using PACNET dll PACNET dll is a net Compact framework SDK and PACNET dll is not only used for C program but also used for VB net program The latest version of this library is located at PACNET dll the execution file should be put in the same directory of the CD root Xpac Atom SDK PACSDK Driver DOTNET in the companion CD http ftp icpdas com pub cd xpac atom sdk pacsdk driver dotnet Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Tools Test Window Help Save All Chile Shifts Recent Files Recent Projects Exit PAC Standard API Manual v1 1 0 Copyright 2013 ICP DAS Co Ltd All Rights Reserved bs Project Shitty Web Site Shitty AlN T3 CtieN Project From Existing Code Last Revised Jan
121. UU 15 1 1 Introducing the PACSDK ccsisssisisccceindesvccnsstssauceaselersedessescesuisucasdsgaudbacedeebdeazeden 15 1 Copying the PACSDNK ioi 17 1 3 Setting up the Development Environment cesses ecce eese eene enne enne 19 1 3 1 C C based on Visual Studio 20 1 3 2 Visual CH 23 1 3 3 VB net 30 1 3 4 Visual Basic 6 0 37 2 PAC AP FUNCTIONS iore aes essa hebetes ln eaae EVRAR 40 2 1 System Information APh sio opo ici are 41 2 1 1 pac GetModuleName 46 2 1 2 pac GetRotaryID 48 2 1 3 pac GetSerialNumber 50 2 1 4 pac GetSDKVersion 52 2 1 5 pac ChangeSlot 54 2 1 6 pac CheckSDKVersion 57 2 1 7 pac ModuleExists 59 2 1 8 pac GetOSVersion 62 2 1 9 Pac GetCPUVersion 64 2 1 10 Pac EnableLEDs 66 2 1 11 pac GetModuleType 68 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 3 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 12 pac_BuzzerBeep 71 2 1 13 pac_GetBuzzerFreqDuty 73 2 1 14 pac_SetBuzzerFreqDuty 75 2 1 15 pac_StopBuzzer 77 2 1 16 pac_GetDIPSwitch 78 2 1 17 pac_GetSlotCount 79 2 1 18 pac GetBackplanelD 80 2 1 19 pac GetBatteryLevel 82 2 1 20 pac EnableRetrigger 84 Por EE sgg RE 85 2 2 1 pac RegisterSlotInterrupt 88 2 2 2 pac UnregisterSlotInterrupt 90 2 2 3 pac EnableSlotInterrupt 92 2 2 4 pac SetSlotInterruptPriority 94 2 2 5 pac Inte
122. 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 0 Last Revised January 2013 Page 189 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 9 uart_EnableCheckSum This function turns on the check sum or not Add two checksum 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 190 Examples C HANDLE hUart char result 32 hUart uart_Open uart_EnableCheckSum hUart true pac_ChangeSlot
123. Y pac_UnregisterSlotInterrupt Y Y Y Y Y Y Y Y pac EnableSlotInterrupt Y Y Y Y Y Y Y Y pac SetSlotInterruptPriority Y Y Y Y Y Y Y Y pac Interruptlnitialize Y Y Y Y Y Y Y Y pac GetSlotInterruptEvent Y Y Y Y Y Y Y Y pac SetSlotInterruptEvent Y Y Y Y Y Y Y Y pac SetTriggerType Y Y Y Y Y Y Y Y pac GetSlotInterruptiD Y Y Y Y Y Y Y Y pac_InterruptDone Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 433 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Memory Access Functions Functions Models XP 8000 XP 8000 Atom XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8xox WP 5xxx VP 25Wx VP 23Wx pac GetMemorySize Y Y Y Y Y Y Y YA Y Y pac ReadMemory Y Y Y Y Y Y Y YA Y Y pac WriteMemory Y Y Y Y Y Y Y YA Y Y pac EnableEEPROM Y Y Y Y Y Y Y Y Y Y 8541 FRANS BACK Y Y Y Y Y SEA RTAS IRSKE Y Y Y Y Y SEA KAISER y Y Y Y Y SEA RTAS RRIA 5 2 Y Y Y Y Y A WP 5xxx only supports the memory type 1 EEPROM not type 0 SRAM PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 434 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Watchdog Functions Functions Models XP 8000 XP 8000 Atom PC pac_EnableWatchDog Y Y Y Y Y Y Y Y Y Y pac_Dis
124. _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 TotalCh 8 float fValue BOOL iRet pac ReadAO O iSlot iChannel iAO_TotalCh amp fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 269 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 TotalCh 8 float fValue bool iRet PACNET IO ReadAO hPort iSlotiiChannel 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 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 270 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 15 pac_ReadAl This function reads the engineering mode Al value of the Al module Syntax C BOOL pac ReadAI HANDLE hPort int slot int iChannel int iAl_ TotalCh float fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 271 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parame
125. ableWatchDog Y Y Y Y Y Y Y Y Y Y pac_RefreshWatchDog Y Y lt Y Y Y Y Y Y Y Y pac_GetWatchDogState Y Y Y Y Y Y Y Y Y Y pac GetWatchDogTime Y Y Y Y Y Y Y Y Y Y pac SetWatchDogTime Y Y Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 435 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Registry Functions Functions Models pac_RegCountKey XP 8000 CE6 lt XP 8000 Atom CE6 WP 8x4x WP 8x3x lt lt lt WP 8x5x lt WP 5xxx lt VP 25Wx lt VP 23Wx lt pac_RegCountValue pac_RegCreateKey pac_RegDeleteKey pac_RegDeleteValue pac_RegGetDWORD pac_RegGetKeyBylndex pac RegGetKeylInfo pac RegGetsString pac RegGetValueByIndex pac RegKeyExist pac RegSave pac RegSetString lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt
126. ackplanelD retrieves the backplane ID of the XPAC pac GetBatteryLevel Sys GetBatteryLevel retrieves the battery status of the backplane and the RTC battery status of the CPU board pac_EnableRetrigger Sys EnableRetrigger determines the retrigger status PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 45 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 1 pac_GetModuleName This function retrieves the name of the specified I O module plugged into the XPAC series devices Syntax C int pac_GetModuleName BYTE slot LPSTR strName Parameters Slot in Specifies the slot number to which module is plugged to XPAC series devices strName out A pointer to a buffer that receives the name of the specified I O module Return Value If the 8K I O module is undefined the return value is some other value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 46 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C byte slot 1 char strName 10 pac_GetModuleName slot strName CH For this API there are two ways to get the module name Firstis called by reference and you should add key word ref The return value is Module type not Module name byte slot 1 string strName int ModuleType 0 ModuleType PACNET Sys GetModuleName slot ref st
127. al v1 1 0 Last Revised January 2013 Page 221 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 value 4 turn on the channel two BOOL ret pac WriteDO MF hPort PAC REMOTE 10 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 0 Last Revised January 2013 Page 222 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteDO Example 1 f 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 WriteDO hPort PACNET IO REMOTE 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 hPort 1 total channel do value PACNET UART Close hPort Example 3 If the module is 8k local
128. al port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that the counter value belongs iDI 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 0 Last Revised January 2013 Page 255 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDICNT Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDI TotalChz8 DWORD ICounter_ Value uart_Close hPort Example 2 If the module is 8k local BYTE iSlot 1 int iChannel 22 int iDI TotalChz8 DWORD ICounter_ Value BOOL iRet pac_ReadDICNT hPort iSlot iChannel iDI_TotalCh amp lCounter_Value BOOL iRet pac ReadDICNT O iSlot iChannel iDI TotalCh amp lCounter_Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 256 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C pac_ReadDI
129. alth 8 Local I O Function PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 206 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remote If remote mode the address need call a macro PAC REMOTE And its range is from 0 to 255 For example as follow Write DO value to remote module HANDLE hPort uart_Open ConnectionString if thPort AfxMessageBox _T 0pen Com Error pac_WriteDO hPort PAC_REMOTE_I0 iAddr m_iDOCHs 100 Value Com 3 ed Remote I O Function L H mj PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 207 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 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 1 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
130. another pac_CheckSDKVersion Sys CheckSDKVersion is used to compare the version number of the currently used PACSDK dll with the specified version number pac ModuleExists Sys ModuleExists specifies whether the local module exist in the XPAC or not pac GetOSVersion Sys GetOSVersion retrieves the version number of the XPAC current operating system OS Pac GetCPUVersion Sys GetCPUVersion retrieves the version number of the XPAC CPU board Pac EnableLEDs Sys EnableLEDs sets the state of the specified LED pac GetModuleType Sys GetModuleType retrieves the type of I O modules pac BuzzerBeep Sys Buzzer BuzzerBeep generates simple tones on the speaker pac GetBuzzerFreqDuty Sys Buzzer GetBuzzerFreqDuty retrieves the frequency value and duty cycle value of the buzzer pac SetBuzzerFreqDuty Sys Buzzer SetBuzzerFreqDuty sets the frequency value and duty cycle value of the buzzer pac StopBuzzer Sys Buzzer StopBuzzer stops the buzzer PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 44 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_GetDIPSwitch Sys GetDIPSwitch retrieves the dip switch on the XPAC pac_GetSlotCount Sys GetSlotCount retrieves the total number of the IO slot on the XPAC pac_GetBackplanelD Sys GetB
131. anuary 2013 Page 396 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 5 pac SetBPTimerlnterruptPriority This function sets the priority for a real time thread of the backplane timer Syntax C bool pac SetBPTimerlnterruptPriority int type int nPriority Parameters type in Specifies the backplane timer 0 Timerout 1 Timer 1 2 Timer 2 nPriority in Priority 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 FLASE PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 397 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 SetBPTimerlnterruptPriority 1 100 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 398 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 i
132. are same on the PAC API manual Refer to the following figure void test i PACNET ER BP Timer class PACNET BP Time EP EnCode Backplane timer API EnHendling Interrupt Rg Memory 4 MISC lt j PAC_CALLBACK_FUNC 4 PAC IO Rg PAC Reg void test PACNET Sys ChangeSlot j Sys ChangeSlot byte slotNo b slotNo in Specifies 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 e PACNET dll PACNET XML PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 461 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 0 Last Revised January 2013 Page 462 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Add Basic PAC_ERR_MODULE_UN
133. art_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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel freq in The frequency value to set to the PWM module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 360 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 unsigned long ulfreq 1 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong ulfreg 1 PACNET UART Close hPort iRet pac_SetPWMFrequency hPort iSlot iChannel ulfreq bool iRet PACNET PWM SetPWMFrequency hPort iSlot iChannel ulfreq PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 361 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 4 pac_GetPWMFrequency This function reads the frequency value for a specific channel Syntax C bool pac_GetPWMFrequency HANDLE port int slot short chlndex unsigned long fr
134. ation 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 0 Last Revised January 2013 Page 393 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 Interrupt done Set timer1 with 200 microsecond interval pac_SetBPTimer 1 200 TIMER PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 394 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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
135. c_GetSlotCount This function retrieves the total number of the IO slot on the XPAC 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 CH int iSlot iSlot PACNET Sys GetSlotCount Console WriteLine The number of the IO slot is iSlot ToString Console ReadLine PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 79 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 18 pac GetBackplanelD This function retrieves the backplane ID of the XPAC Syntax C void pac GetBackplanelD LPSTR backplane version Parameters backplane version out Retrieves the backplane ID Return Value This function has does not return any value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 80 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C char Backplane 32 pac GetBackplanelD Backplane CH string Backplane Backplane PACNET Sys GetBackplanelD Console WriteLine The Backplane ID is Backplane Console ReadLine The example displays the following output to the console The Backplane ID is 1 0 10 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page
136. ceeds 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 0 Last Revised January 2013 Page 119 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C DWORD second 10 bool ret ret pac_EnableWatchDog PAC_WDT_OS second CH int PAC WDT OS 1 uint second 10 bool ret err Remarks Enable the OS watchdog and set the reset time 10 seconds ret err PACNET Sys WDT EnableWatchDog PAC WDT OS second The unit of the parameter value for OS watchdog is second In addition the value cannot be zero for XPAC series only The value of the parameter value for hardware watchdog is limited to the range of 0763 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 120 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 Hardware watchdog PAC_WDT_HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PA
137. ch 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 0 Last Revised January 2013 Page 249 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI TotalChz8 int iDO_TotalCh 8 int iLatchType 0 DWORD IDI Latch Value DWORD IDO Latch Value BYTE cDI Latch BitValue BYTE cDO Latch BitValue BOOL iRet pac ReadDlOLatch hPort iSlot iDI TotalCh iDO TotalCh iLatchType amp IDI Latch Value amp IDO Latch Value uart Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iDI TotalChz8 int iDO_TotalCh 8 int iLatchType 0 DWORD IDI Latch Value DWORD IDO Latch Value BYTE cDI Latch BitValue BYTE cDO Latch BitValue BOOL iRet pac ReadDlOLatch O iSlot iDI TotalCh iDO TotalCh iLatchType amp IDI Latch Value amp IDO Latch Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 250 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 iLatchType 0 uint IDI
138. changed will take effect until the end of the program PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 76 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 15 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 any value Examples C pac StopBuzzer CH Demonstrate how to stop the buzzer PACNET Sys Buzzer BuzzerBeep 1 10000 Console ReadLine Press any key to stop the buzzer PACNET Sys Buzzer StopBuzzer PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 77 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 16 pac_GetDIPSwitch This function retrieves the dip switch on the XPAC HARBOUR Syntax C int pac_GetDIPSwitch Parameters This function has no parameters Return Value The return value specifies the dip switch Examples C int iDipSwitch iDipSwitch pac_GetDIPSwitch CH int iDipSwitch iDipSwitch PACNET Sys GetDIPSwitch Console WriteLine The DIP Switch value is iDipSwitch ToString Console ReadLine PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 78 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 17 pa
139. cific channel pac_GetPWMMode PWM GetPWMMode reads the continuous mode for a specific channel pac_SetPWMDITriggerConfig PWM SetPWMDITriggerConfig sets the hardware trigger for a specific channel pac_GetPWMDITriggerConfig PWM GetPWMDITriggerConfig reads the hardware trigger for a specific channel pac_SetPWMsStart PWM SetPWMStart sets the status of the PWM output port pac_SetPWMSynChannel PWM SetPWMSynChannel sets the PWM synchronization status for a specific channel pac GetPWMsSynChannel PWM GetPWMsSynChannel reads the PWM synchronization status for a specific channel pac SyncPWMSsStart PWM SyncPWMStart starts the PWM synchronization pac SavePWMConfig PWM SavePWMcConfig saves the PWM configuration pac GetPWMDIOStatus PWM GetPWMDIOStatus reads the status of the PWM output port and the digital input port pac SetPWMPulseCount PWM SetPWMPulseCount sets the PWM step value for a specific channel pac GetPWMPulseCount PWM GetPWMPulseCount reads the PWM step value for a specific channel 2 8 1 pac SetPWMbDuty This function sets the duty cycle value for a specified channel Syntax C bool pac_SetPWMDuty HANDLE port int slot short chlndex 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
140. code to complete your project Click Project Add Reference Choose PACNET dll from the list Click OK to add the reference Use the intellisense feature to quickly select the function which you want to call pA qux des Example Microsoft Visual Studio ER File Edit View Project Build Debug Data Tools Test Window Help ai oe at 9 0 3 5 b Debug C3 ax Forml vb Fonnivb Design Start Page F Forml Events v y Load Claes Forni l LESS amp E Example i HH Sa My Project ata E al sende em Obje b E Reference PACNET CG PACNET nd Sut 4 TN Cass BF Tier E Enf Class 59 EnCode ra 42 System Core t Interrupt D System Data DataSe pi Memory 42 System Deployme MISC 43 System Drawing Aj PAC_CALLBACK_FUNC 43 System Windows PAC IO 2 System Xml 9 PAC Reg 42 System Xml Ling amp PWM v amp bin fH i1 obj a Forml vb You can add the the namespace Imports PACNET to your code and it can simplify object names Such as PAC IO GetBit instead of PACNET PAC IO GetBit PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 36 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 4 Visual Basic 6 0 Required header and library files The following list lists the libraries or DLL files you will need to include to develop a XPAC PC application or
141. configuration specific PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 22 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 2 Visual C Required library files The following DLL files are needed to include for developing a XPAC PC application or plug in gt PACSDK dll 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 1 Start Visual Studio NET 2 Click gt File New gt Project Edit View Tool Test Window Help ipd Project Chl ShifttN Web Site Shaft Fil Chl N Project From Existing Code ER Save AD Chile Shift Recent Files Recent Projects Exit PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 23 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 Inthe Project Type column choose Visual C gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project Hew Project NETFmmewok35 EGA Project types Templates E Visual C Windows Web Windows Forms Application Class Library Smart Device ret 5 WEF Application Pay WPF Browser Application Offi Cli Cons
142. cpdas 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 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 0 Last Revised January 2013 Page 156 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 157 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 y Parameters KeyName in Specific the path of registry key which you want to assign data as
143. ction fails the return value is FALSE PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 341 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 0 short sStatus 0 unsigned long ulWDTtime 0 int iOverwrite 0 hPort uart_Open pac SetModuleWDTConfig hPort iSlot sStatus ulWDTtime iOverwrite uart Close hPort CH f the module is 87k local IntPtr hPort int iSlot 0 short sStatus 0 unsigned long ulWDTtime 0 int iOverwrite 0 hPort PACNET UART Open PACNET IO SetModuleWDTConfig hPort iSlot sStatus ulWDTtime iOverwrite 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 342 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 OpenY if the module is 87k modules in local slot
144. d PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 386 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 long lcnt uart Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 long lcnt PACNET UART Close hPort BOOL iRet pac GetPWMPulseCount hPort iSlot iChannel amp lcnt bool iRet PACNET PWM GetPWMPulseCount hPort iSlot iChannel ref lcnt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 387 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 Last Revised January 2013 Page 388 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_GetBPTimerTim
145. d API Manual v1 1 0 Last Revised January 2013 Page 130 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 using the registry functions PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 131 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the registry functions Functions Models pac_RegCountKey XP 8000 CE6 Y XP 8000 Atom CE6 Y WP 8x4x Y WP 8x3x Y WP 8x5x Y WP 5xxx Y VP 25Wx Y VP 23Wx Y pac RegCountValue pac RegCreateKey pac RegDeleteKey pac RegDeleteValue pac RegGetDWORD pac RegGetKeyBylIndex pac RegGetKeylInfo pac RegGetsString pac RegGetValueByIndex pac RegKeyExist pac RegSave pac RegSetString pac RegSetDWORD lt lt lt lt lt lt lt lt lt lt X lt x lt lt lt lt REIR XR XR LX lt lt lt lt xx lt lt lt XR LX lt lt x lt lt lt lt IRR XR LX lt lt lt lt xx REIR XR XR DL l
146. d API Manual v1 1 0 Last Revised January 2013 Page 466 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 C VB net project required to refer to PACNET dll while building and the built executable file place
147. d fail PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret DWORD index 0 TCHAR strName 10 ret pac_RegGetValueBylndex TEXT HKEY_USERS myKey index strName CH 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 0 Last Revised January 2013 Page 153 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 11 pac RegKeyExist This function determinants the specified registry key exists or not Syntax C BOOL pac RegKeyExist LPCSTR 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 the registry key exists otherwise false PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 154 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool bExist bExist pac_RegKeyExist TEXT HKEY_USERS myKey CH bool bExist bExist WinPAC RegKkeyExist HKEY_USERS myKey PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 155 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service i
148. d in the WinPAC series device must work with PACNET dll and PACSDK dll Project Link PACNET dll PC WinPAC PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 467 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 1 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 0 Last Revised January 2013 Page 468 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 XPacSDK CElib The C
149. e PACNET UART Close hPort Example 2 f 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 MrF 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 315 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 kh 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 0 Last Revised January 2013 Page 316 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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
150. e 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 BOOL iRet pac ClearDlOLatch 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 ClearDIOLatch 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 253 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 iDI TotalCh DWORD ICounter Value b C for pac_ReadDICNT_MF BOOL pac ReadDICNT MF HANDLE hPort int slot int iChannel int iD TotalCh DWORD ICounter Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 254 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Parameters hPort in The seri
151. e current pac GetCurrentDirectoryW mE application PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 414 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 11 1 AnsiString This function converts a unicode string to an ANSI byte array Syntax Ci byte AnsiString in string str Parameters str in Points to the Unicode string to be converted Return Value Returns the ANSI byte array Examples CH 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 00M result string str PACNET MISC WideString result PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 415 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 416 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 11 2 WideString This function converts an ANSI byte array to Unicode string Syntax Ci string WideString byte CharStr Parameters CharStr in Points to the ANSI byte array to be converted Return Value Returns the Unicode string Examples CH
152. e is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 0 255 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 0 Last Revised January 2013 Page 347 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C Example 1 int CALLBACK slot_callback_proc do something return true int iSlot 0 pac InitModuleWDrTInterrupt iSlot slot callback proc CH PACNET CALLBACK_FUNC slot_callback_proc global int slot_callback_proc do something return 0 int iSlot 0 PACNET 10 InitWoduleWDTInterrupt iSlot slot callback proc PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 348 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro PAC REMOTE 10 0 255 Return Value Interrupt status PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 349 Copyright
153. e of the Al module The function maybe causes the buffer overflow in some situation Syntax C BOOL pac ReadAIAII 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 0 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 module is remote please use the macro 0 255 fValue out The array contains the Al values that 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 0 Last Revised January 2013 Page 283 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAll hPort iSlot fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAll 0 iSlot fValue CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 float fValue 8 bool iRet PACNET IO ReadAIAll hPort iSlot fValue PACNET UART Close hPort Remarks The function can support for Local or R
154. eTick_ms Y N N Y Y Y Y pac_GetBPTimerTimeTick_us Y N N Y Y Y Y pac_SetBPTimer Y N N Y Y Y Y pac_SetBPTimerOut Y N N Y Y Y Y pac SetBPTimerlnterruptPriority Y N N Y Y Y Y pac KillBPTimer Y N N Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 389 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Backplane Timer Functions The following functions are used to retrieve or set the backplane timer PACSDK Functions 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 i i started excluding any time that the system was suspended pac SetBPTimer BPTimer SetBPTimer creates a hardware timer with the specified time out value 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 SetBPTimerOut BPTimer SetBPTimerOut creates a hardware timer with the specified time out value of high low wave PAC Standard API Manual v1 1 0 Last Revised January 2013 Page
155. eadModulePowerOnValueAO hPort iSlot iChannel iAO TotalCh ref fValue PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 330 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 331 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 module is remote please use the macro PAC REMOTE 0 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 332 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 others maybe poer on value or regular
156. ebox correctly Remarks The maximum size of the string buffer is 2 Kbytes PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 420 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 421 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 0 Last Revised January 2013 Page 422 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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
157. ecified memory Syntax C BOOL pac_ReadMemory DWORD address LPBYTE lpBuffer DWORD dwLength int mem type PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 108 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Parameters address in Specifies the memory address where read from EEPROM 0 Ox1FFF 8KB for users 0x2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only 0 Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system lpBuffer in Receives the memory data dwLength in Number of characters to be read mem type in Handle to a currently type memory 0 PAC MEM SRAM 1 PAC MEM EEPROM 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 0 Last Revised January 2013 Page 109 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C define LENGTH 2 bool ret DWORD address 0 BYTE Buffer LENGTH ret pac_ReadMemory address Buffe
158. ed D lt E mail service icpdas com Return Value If the function succeeds the return value is 1 If the function fails the return value is 0 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 CH 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 PurgeCommY to clear serial COM port output buffer PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 195 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 12 uart_BinRecv 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 c
159. ed index of registry key pac_RegKeyExist PAC Reg RegKeyExist determinants the specified registry key exists or not pac RegSave PAC Reg RegSave writes all the attributes of the specified open registry key into the registry pac RegSetsString PAC_Reg RegSetString assigns the specified registry key data whose type is string pac_RegSetDWORD PAC Reg RegSetDWORD assigns the specified registry key data whose type is DWORD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 133 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt 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 LPCSTR 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 134 Examples C DWORD i i pac_RegCountKey TEXT HKEY_USERS myKey CH uint i i PACNET PAC_Reg RegCountKey HKEY_USERS S 1 5 18 Console WriteLine The number of subkeys is i ToString Console ReadLine The example displays the following output to the console
160. emote 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 284 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 19 pac_ReadAIAllHexExt This function reads all the Al values of all channels in 2 s complement mode of the Al module This function replaces pac_ReadAIAllHex Syntax C BOOL pac_ReadAIAllHex HANDLE hPort int slot int iValue DWORD Buff Len DWORD Channel PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 285 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 255 iValue out The array contains the Al values that read back from the Al 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 This channel number is only valid if the return value is
161. en 0 bExist PACNET Sys ModuleExists hPort 5 if bExist Console WriteLine A module exists in the slot 5 of the XPAC else Console WriteLine No module exists in the slot 5 of the XPAC Console ReadLine f there is a local module in the slot 5 of a XPAC the output to the console is as below A module exists in the slot 5 of the XPAC Else the output to the console is as below JJ No module exists in the slot 5 of the XPAC PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 60 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks When you have ever sended a command to a local module on the slot and an error happened you can add the Pac_ModuleExists function into your program before sending command to the module By this way You can quickly check whether a module correctly exists in the slot and save the waiting time for the timeout if a module does not exist PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 61 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 8 pac GetOSVersion This function retrieves the version number of the XPAC current operating system OS Syntax C void pac_GetOSVersion LPSTR os version Parameters os version out The version number of the XPAC OS Return Value This function does not return any value PAC Standard
162. eq 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel freq in The frequency value to read to the PWM module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 362 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 unsigned long ulfreq uart Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 ulong ulfreq 1 PACNET UART Close hPort BOOL iRet pac_GetPWMFrequency hPort iSlot iChannel amp ulfreq bool iRet PACNET PWM GetPWMFrequency hPort iSlot iChannel ref ulfreq PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 363 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 5 pac_SetPWMMode This function sets the continuous mode for a specific channel Syntax C bool pac_SetPWMMode
163. er 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 0 Last Revised January 2013 Page 179 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 larger 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 0 Last Revised January 2013 Page 180 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt 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
164. es 1 The each of API function is used for the DCON module which is provided with Power ON or Safe value function 2 7K I 87K series modules provided with Power ON or Safe Value function can support the API functions above I 8K series module provide the functions is only I 8041RW PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 448 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 4 Add I O accessing API functions for the Multi function modules The new PACSDK dll provides the support of I O accessing functions including Write Read DIO AIO Read DI counter and I O 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 ReadDIO MF pac ReadDI MF pac ReadDO MF pac ReadDIO DIBit MF pac ReadDIO 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 0 Last Revised January 2013 Page 449 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Notes 1 The fu
165. es 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_RegGetDWORD pac RegGetKeyByIndex pac RegGetKeyInfo pac RegGetsString pac RegGetValueByIndex pac RegKeyExist pac RegSave pac RegSetString pac RegSetDWORD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 446 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 I O 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 InitModuleWDTlInterrupt pac SetModuleWDTlInterruptStatus pac GetModuleWDTlInterruptStatus pac ReadModuleSafeValueDO pac WriteModuleSafeValueDO pac ReadModuleSafeValueAO pac WriteModuleSafeValueAO pac ReadModulePowerOnValueDO pac WriteModulePowerOnValueDO pac ReadModulePowerOnValueAO pac WriteModulePowerOnValueAO PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 447 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Not
166. etrieve 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 0 Last Revised January 2013 Page 98 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 99 2 2 9 pac_GetSlotinterruptiD This function retrieves the ID of the slot interrupt Syntax C DWORD pac_GetSlotInterrupt D 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 function has no examples PAC Standard API Manual v1 1 0 Last Revised January 20
167. eturns 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 0 Last Revised January 2013 Page 402 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 403 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 O 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 codes use the pac_GetErrorMessage function For a complete list of error codes see Appendix A System Error Code The fol
168. f the system information functions Functions Models pac_GetModuleName XP 8000 Y XP 8000 Atom Y PC XP 8000 CE6 Y XP 8000 Atom CE6 Y WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx Y Y Y Y Y Y pac GetRotaryID pac GetSerialNumber pac GetSDKVersion lt lt lt pac_ChangeSlot pac CheckSDKVersion pac ModuleExists pac GetOSVersion Pac GetCPUVersion lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt Pac_EnableLEDs pac_GetModuleType pac_BuzzerBeep pac_GetBuzzerFreqDuty pac_SetBuzzerFreqDuty pac_StopBuzzer lt lt lt lt lt lt lt lt lt lt lt lt pac_GetDIPSwitch pac_GetSlotCount pac_GetBackplanelD pac_GetBatteryLevel pac_EnableRetrigger lt x lt lt lt lt lt lt lt lt lt lt lt lt Jx pac_GetMacAddress lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt
169. feValueDO hPort PAC REMOTE 10 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 WriteModuleSafeValueDO hPort 1 total channel do value uart Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 302 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO_MF Example 1 f 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 10 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 MrF hPort 1 total channel do value uart Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 303 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO Example 1 If 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
170. ge 126 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail 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 0 Hardware watchdog PAC WDT HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PAC WDT OS Return Value The return value is the watchdog time which has been assigned by pac EnableWatchDog or pac SetWatchDogTime For OS watchdog the unit of the return value is second and for hardware watchdog the return value is between 0763 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 127 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C DWORD dwTime dwTime pac_GetWatchDogTime PAC_WDT_OS CH uint uTime uTime PACNET Sys WDT GetWatchDogTime 1 Console WriteLine The watchdog time is uTime ToString Console ReadLine The example displays the following output to the console The watchdog time is 10 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 128 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 6 pac SetWatchDogTime This function starts a watchdog operation The unit of the parameter value for OS
171. ge 288 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 20 pac_ReadAIAllHex 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_ReadAIAllHex 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 0 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 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 Al module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 289 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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_ReadAIAllHex hPort iSlot iValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iValue 8 BOOL iRet pac ReadAIAIIHex 0O iSlot iValue CH f the module is 87k local IntPtr hPort hPo
172. gt lt 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 92 Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something pac_InterruptDone slot return true void CIntrDlg OnButton1 void CIntrDlg OnButton2 Remarks Default trigger type is level trigger For XP 8000 series only support level trigger type pac RegisterSlotInterrupt slot slot callback proc 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 pac EnableSlotInterrupt slot true enable slot interrupt pac EnableSlotInterrupt slot false disable slot interrupt pac UnregisterSlotInterrupt slot unregister slot interrupt
173. h runs with x86 based PaCSDK dll PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 454 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service 2icpdas 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 API function classification All API functions for the WinPacNet dll or the XPacNet dll are placed in a single WinPacNet WinPAC xxx XPacNET XPac xxx class but the API functions for the PACNET dIl 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 manual are as follows Classification in the API Manual Class Name in PACNET dIl 2 1 System Information API Sys 2 1 System Information API Sys Buzzer 2 2 Interrupt API Interrupt 2 3 Memory Access API Memory 2 4 Watchdog API Sys WDT 2 5 Registry API PAC Reg 2 6 UART API UART 2 7 PAC IO API PAC IO 2 8 PWM API PWM 2 9 Backplane Timer AP
174. hecksum 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 Lb 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 0 Last Revised January 2013 Page 196 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Return Value If the function succeeds the return value is 1 If the function fails the return value is 0 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 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 1 7000 8000 87K series modules PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 197 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 13 uart_BinSendCmd This func
175. hort 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 SetPWMsStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 373 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 int slot short chlndex 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 module is remote please use the macro PAC REMOTE 0 255 chindex in Set the duty cycle value from the channel config in 0 Disables the PWM synchronization 1 Enables the PWM synchronization PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 374 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open
176. ice versa PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 209 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PAC_IO functions VP 23Wx Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx pac_GetBit Y Y Y Y Y Y Y pac WriteDO pac WriteDO MF Y Y Y Y Y Y Y pac WriteDOBit Y Y Y Y Y Y Y pac ReadDO pac ReadDO MF Y Y Y Y Y Y Y pac ReadDl pac ReadDI MF Y Y Y Y Y Y Y pac ReadDIO pac ReadDIO MF Y Y Y Y Y Y Y pac ReadDlLatch Y Y Y Y Y Y Y pac ClearDlLatch Y Y Y Y Y Y Y pac ReadDlOLatch Y Y Y Y Y Y Y pac ClearDlOLatch Y Y Y Y Y Y Y pac ReadDICNT pac ReadDICNT MF Y Y Y Y Y Y Y pac ClearDICNT pac ClearDICNT MF Y Y Y Y Y Y Y pac WriteAO pac WriteAO MF Y Y Y Y Y Y Y pac ReadAO Y Y Y Y Y Y Y pac_ReadAl Y Y Y Y Y Y Y pac ReadAlHex Y Y Y Y Y Y Y pac ReadAIAIIExt Y Y Y Y Y Y Y pac ReadAIAII Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 210 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com pac ReadAIAIIHexExt pac ReadAIAIIHex pac ReadCNT pac ClearCNT pac ReadCNTOverflow pac WriteModuleSafeValueDO pac Write ModuleSafeValueDO MF pac ReadModuleSafeValueDO pac ReadM oduleSafeValueD
177. ied hardware interrupt pac SetSlotInterruptPriority Interrupt SetSlotInterruptPriority sets the priority for a real time thread on a thread by thread basis pac_Interruptinitialize Interrupt Interruptlnitialize initializes a slot interrupt with the kernel This initialization allows the slot to register an event and enable the interrupt pac GetSlotInterruptEvent Interrupt GetSlotInterruptEvent retrieves the slot event handle which registered by pac Interruptlnitialize pac SetSlotInterruptEvent Interrupt SetSlotinterruptEvent sets the priority for a real time thread on a thread by thread basis pac SetTriggerType Interrupt SetTriggerType assigns the pulse trigger type for separate slot pac GetSlotInterruptID Interrupt GetSlotInterruptID retrieves the ID of the slot interrupt pac InterruptDone Interrupt InterruptDone signals to the kernel that interrupt processing has been completed PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 87 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com 2 2 1 pac_RegisterSlotinterrupt This function registers the slot interrupt service route after turning on the slot interrupt Syntax C pac RegisterSlotInterrupt BYTE slot PAC CALLBACK FUNC f Parameters slot in Specifies the index of slot On the XPAC the index of slot starts from
178. ies The following table shows the defined values Value Description 0 No module existed 0x80 Genernal I 8000W module 0x81 I 8000RW module R version Provide PowerOn and Safe value OxE3 I 8000W module with 32 DI channels OxEO I 8000W module with 32 DO channels OxE2 I 8000W module with 16 DI channels and 16 DO channels OxC3 I 8000W module with 16 DI channels OxCO I 8000W module with 16 DO channels 0xC2 I 8000W module with 8 DI channels and 8 DO channels 0x40 No module defined PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 69 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int iDIO Slot 1 int Type 0 Type pac GetModuleType iDIO Slot if Type Oxe2 Type Oxc2 The module is DIO module CH byte slot 1 int ModuleType 0 ModuleType PACNET Sys GetModuleType slot if ModuleType 0xCO else Console ReadLine the output to the console is as below The module type value is 40 Console WriteLine The module is an I 8000W module with 16 DO channels Console WriteLine The module type value is Convert ToString ModuleType 16 f an I 8000W module with 16 DO channels plugged into slot 1 The module is an I 8000W module with 16 DO channels Else output the module type to the console as below PAC Standard API Manual v1 1 0 Last Revised January 2013
179. in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 0 255 iChannel in The total number of DO channels of the DO modules IValue 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 uart_Close hPort BOOL ret pac_ReadModulePowerOnValueDO hPort slot total channel amp do value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 317 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 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_MF hPort slot total channel amp do_value uart_Close hPort
180. information about the definition of error codes please refer to pac_GetLastError in this document PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 406 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 requested message lpBuffer 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 0 Last Revised January 2013 Page 407 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com Examples C int main int argc char argv if argc lt 3 printf usage ReadMemory address dwLength mem type n n printf whereWn printf addressAn 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 BYTE buffer 4096 BOOL err char strErr 32 memset buffer 0 4096 if atoi argv 3 0 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
181. int total channel 8 uintdo value 4 turn on the channel two bool ret PACNET IO WriteDO 0 1 total channel do value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 223 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteDO_MF Example 1 f the module is remote int total_ channel 8 uintdo value 4 turn on the channel two do value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort hPort PACNET UART Open int total_channel 8 uintdo value 4 turn on the channel two PACNET UART Close hPort Remarks IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 bool ret PACNET IO WriteDO MF hPort 1O 1 total channel bool ret PACNET IO WriteDO MF hPort 1 total channel do value 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 224 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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
182. ion 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 Series CD XP 8000 Document http www icpdas com products PAC xpac download xpac_wes download_documents h tm XP 8000 Atom Series CD XPAC ATOM Document http www icpdas com products PAC xpac download atom_wes download documents htm PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 12 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com How to contact us For support for this or any ICP DAS product you can contact ICP DAS Customer Support in one of the following ways gt Visit the ICP DAS Storage Manager technical support Web site at http www icpdas com fag fag 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 0 Last Revised January 2013 Page 13 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Revision History The table below shows the revision history Date Description 1 0 1 August 2013 Initial issue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 14 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 1 Getting Started Thi
183. iption 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 0 Last Revised January 2013 Page 150 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret TCHAR strName 10 ret pac_RegGetString TEXT HKEY_USERS myKey value strName sizeof strName CH 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 0 Last Revised January 2013 Page 151 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 RegGetValueByIndex LPCSTR KeyName DWORD dwindex LPSTR Parameters KeyName in Specify the path of registry key dwindex in Specify the index of value lpName out Pointer to a buffer that receives the data of the value 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 coul
184. l module pac_ReadAlHex PAC 10 ReadAlHex reads the 2 s complement mode value of the Al module pac ReadAIAIIExt PAC IO ReadAIAIIExt reads all the Al values of all channels in engineering mode of the Al module pac ReadAIAII PAC 10 ReadAIAll reads all the Al values of all channels in engineering mode of the Al module pac ReadAIAIIHexExt PAC IO ReadAIAIIHexExt reads all the AI values of all channels in 2 s complement mode of the Al module pac ReadAIAllHex PAC IO ReadAIAllHex reads all the AI values of all channels in 2 s complement mode of the Al module pac ReadCNT PAC 10 ReadCNT reads the counter values of the counter frequency modules pac_ClearCNT PAC 10 ClearCNT pac_ClearCNTclears the counter values of the counter frequency modules pac_ReadCNTOverflow PAC 10 ReadCNTOverflow clears the counter overflow value of the counter frequency modules pac_WriteModuleSafeValueDO pac_ WriteModuleSafeValueDO_MF PAC IO WriteModuleSafeValueDO PAC IO WriteModuleSafeValueDO MF writes the DO safe values to DO modules pac ReadModuleSafeValueDO pac R PAC IO ReadModuleSafeValueDO reads the safe value of the DO modules PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 214 Copyright 2013 ICP DAS Co Ltd All Rights Reserved E mail service icpdas com eadModuleSafeValueDO_MF PAC 10 ReadModuleSafeValueDO MF pac_WriteModulePowerOnValueDO pac_WriteModulePowe
185. l 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 0 Last Revised January 2013 Page 276 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f 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 TotalCh 8 int iValue BOOL iRet pac_ReadAlHex 0 iSlot iChannel iAl_ TotalCh amp iValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 277 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 PACNET UART Close hPort Remarks bool iRet PACNET IO ReadAlHex hPort iSlot ichannel iAl_ TotalCh ref iValue 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 0 to 255
186. learCNT Y Y Y Y Y Y Y Y pac ReadCNTOverflow Y Y Y Y Y Y Y Y pac WriteModuleSafeValueDO pac Y Y Y Y WriteModuleSafeValueDO MF pac ReadModuleSafeValueDO pac R Y Y Y Y eadModuleSafeValueDO MF pac WriteModulePowerOnValueDO p ac WriteModulePowerOnValueDO M Y Y Y Y F pac ReadModulePowerOnValueDO p ac ReadModulePowerOnValueDO M Y Y Y Y F pac WriteModuleSafeValueAO Y Y Y Y pac ReadModuleSafeValueAO Y Y Y Y pac WriteModulePowerOnValueAO Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 439 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac ReadModulePowerOnValueAO pac GetModuleLastOutputSource pac GetModuleWDTsStatus pac GetModuleWDTConfig pac SetModuleWDTConfig pac ResetModuleWDT pac RefreshModuleWDT pac InitModuleWDTlnterrupt pac GetModuleWDTlInterruptStatus pac SetModuleWDTlInterruptStatus PAC Standard API Manual v1 1 0
187. les eVC VC VS Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 0 int iOverflow uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannelz0 int iOverflow BOOL iRet pac ReadCNT Overflow hPort iSlot ichannel amp iOverflow BOOL iRet pac ReadCNT Overflow 0 iSlot iChannel amp iOverflow PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 298 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com CH f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int ichannel 0 int iOverflow PACNET UART Close hPort Remarks bool iRet PACNET IO ReadCNT Overflow hPort iSlot iChannel ref iOverflow 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 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 299 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 h
188. local slot in The slot in which module is to receive the command Default is local If the module is remote please use the macro PAC REMOTE 0 255 chindex in Get the duty cycle value from the channel duty out The duty cycle value to read to the PWM module PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 358 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 float fValue uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 float fValue PACNET UART Close hPort BOOL iRet pac_GetPWMDuty hPort iSlot iChannel amp fValue bool iRet PACNET PWM GetPWMDuty hPort iSlot iChannel ref fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 359 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 3 pac SetPWMFrequency This function sets the frequency value for a specific channel Syntax C bool pac_SetPWMFrequency HANDLE port int slot short chlndex unsigned long freq Parameters hPort in The serial port HANDLE opened by u
189. lots 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 Slot number N A 173 177 1 173 177 0 03 077 N A 072 COMO N A N A N A N A Backplane Backplane N A Backplane COM1 RS 232 Backplane Backplane Backplane RS 232 RS 232 RS 232 N A COM2 RS 232 RS 232 RS 232 RS 232 RS 485 RS 485 RS 485 RS 485 COM3 RS 485 RS 485 RS 485 RS 485 N A RS 232 RS 485 RS 232 RS 232 COM4 RS 232 RS 485 RS 232 RS 485 RS 232 RS 485 RS 232 RS 485 N A RS 232 N A N A COM5 RS 232 RS 232 RS 232 RS 232 N A N A N A N A Backplane It s RS232 interface used for accessing the I 87K module only PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 472 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com F 1 XP 8041 CE6 COMA COMB RS 232 RS 485 1 RS 232 COM2 COM1 RS 232 RS 232 COM3 RS 485 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 473 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 2 XP 8341 CE6 XP 8741 CE6 COM4 COMS RS 232 RS 485 v 2 e RS 232 COM RS 232 XP 8341 CE6 COM Slot 1 3 XP 8741 CE6 COM Slot 1
190. lowing table lists the system error codes ranges for each function reference Error Type Explanation PAC_ERR_SUCCESS No error success 0x00000 PAC ERR UNKNOWN Aerror which is undefined 0x00001 Basic Defined common error conditions 0x10000 Memory About memory access 0x11000 Watchdog About watchdog 0x12000 Interrupt About interrupt 0x13000 UART About uart protocol 0x14000 IO About modules 0x15000 Users For user 0x20000 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 404 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Page 405 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
191. mounting MicroSD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 103 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 XP 8000 Atom XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP Sxxx VP 25Wx VP 23Wx pac_GetMemorySize Y Y Y Y Y Y Y YA Y Y pac ReadMemory Y Y Y Y Y Y Y YA Y Y pac WriteMemory Y Y Y Y Y Y Y YA Y Y pac_EnableEEPROM Y Y x Y Y Y Y Y Y Y Y iR RTAS RRIA 5 i i Y Y Y Y Y tian KAISER Y Y Y Y Y SEA RTAS RRIA i s Y n Y Y Y SEA KAISER x 5 Y Y Y Y Y A WP 5xxx only supports the memory type 1 EEPROM not type 0 SRAM PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 104 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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_GetMemorySize Memory GetMemorySize retrieves the size of the specified memory pac GetRotaryID Memory ReadMemory retrieves the position number of the rotary switch pac WriteMemory Memory WriteMemory stores data in the specified memory pac EnableEEPROM Memory EnableEEPROM retrieves
192. n has no examples PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 95 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 96 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 6 pac_GetSlotinterruptEvent This function retrieves the slot event handle which registered by pac Interruptlnitialize 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 0 Last Revised January 2013 Page 97 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 SetSlotInterruptEvent BYTE slot HANDLE hEvent Parameters slot in Specifies the index of slot to r
193. nction 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 Link ith Code uilt as inked wit C EXE x86 PACSDK dll x86 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 453 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 built 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 whic
194. nctions pac_WriteDO pac ReadDIO pac_ReadDI 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 AIO or Counters but are equipped with DIO channels Such as the 1 87005W 1 87016W 1 87082W 1 7016 1 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 n both the WinPACSDK dll and the XPACSDK CE dll PAC IO API functions only support access to high profile I 87K I 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 7 series modules 8000 series modules units tM series modules and other OEM ODM DCON modules 5 The comparison table of pac
195. ndard API Manual v1 1 0 Last Revised January 2013 Page 326 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 If the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 uart_Close hPort 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 5 iSlot iChannel iAO_TotalCh fValue PACNET UART Close hPort BOOL iRet pac WriteModulePowerOnValueAO hPort iSlot ichannel iAO_TotalCh fValue bool iRet PACNET IO WriteModulePowerOnValueAO hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 327 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 0 to 7 If remote the second Parameter need use the macro 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 328 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 31 pac_ReadModuleP
196. ne nennen nnne 444 C 1 PACSDK dll modifications and updates eeeeeeeeeeee eene eene eene eene 445 1 pac EnableLED 445 2 Add Registry API for XPAC series 446 3 Add I O WDT PowerOn Safe Value API for pure DIO modules 447 4 Add I O accessing API functions for the Multi function modules 449 5 Add Misc API function for PACSDK 451 6 Add the reserved memory section for XPAC series 451 7 Using the new SDK PACSDK ina C program 452 2 PACNET SDK modifications and updates eeeeeeeee ee eene e e eene nennen 455 1 API function classification 455 2 API functions modification 456 3 Enumerate the error codes 457 4 Using the new SDK PACNET in a CH or VB net program 458 5 Show a tooltip for the classes of PACNET dll 461 C 3 Error code modifications and updates eeeeeee eee eee eene eee eene eene 462 1 For WinPAC series 462 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 9 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 For XPAC series 464 Appendix D Using the Multi function DCON module 466 1 On WinPAC devices 466 2 On XPAC devices 469 Appendix E How to upgrade the WinPACSDK dll XPACSDK dll 471 Appendix F Comparison of Defined Slots and COM Ports 472 Fil XP SO4L CEG Em 473 F2 XP 8341 CEQ XP 874
197. nge 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 0xOD PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 176 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 function automatically adds the two checksum bytes to the string And then the end of sending string is further added OxOD 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 0 Last Revised January 2013 Page 177 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 CH bool ret Int
198. ns Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac SetPWMDuty Y Y Y Y Y Y Y Y pac GetPWMDuty Y Y Y Y Y Y Y Y pac SetPWMFrequency Y Y Y Y Y Y Y Y pac GetPWMFrequency Y Y Y Y Y Y Y Y pac SetPWMMode Y Y Y Y Y Y Y Y pac GetPWMMode Y Y Y Y Y Y Y Y pac_SetPWMDITriggerConfig Y Y Y Y Y Y Y Y pac_GetPWMDITriggerConfig Y Y Y Y Y Y Y Y pac_SetPWMsStart Y Y Y Y Y Y Y Y pac_SetPWMSynChannel Y Y Y Y Y Y Y Y pac_GetPWMSynChannel Y Y Y Y Y Y Y Y pac_SyncPWMStart Y Y Y Y Y Y Y Y pac_SavePWMConfig Y Y Y Y Y Y Y Y pac_GetPWMDIOStatus Y Y Y Y Y Y Y Y pac SetPWMPulseCount Y Y Y Y Y Y Y Y pac GetPWMPulseCount Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 354 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PWM Functions The following functions are used to retrieve or set the PWM PACSDK Functions pac SetPWMDuty PWM SetPWMDuty sets the duty cycle value for a specified channel pac_GetPWMDuty PWM GetPWMDuty reads the duty cycle value for a specific channel pac_SetPWMFrequency PWM SetPWMFrequency sets the frequency value for a specific channel pac_GetPWMFrequency PWM GetPWMFrequency reads the frequency value for a specific channel pac_SetPWMMode PWM SetPWMMode sets the continuous mode for a spe
199. nt type Parameters type in Specifies the timer 0 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 0 Last Revised January 2013 Page 399 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 400 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac_GetLastError Y Y Y Y Y N Y Y pac_SetLastError Y Y Y Y Y N Y Y pac GetErrorMessage Y Y Y Y Y N Y Y Y Y N N N N N Y pac ClearLastError PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 401 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Error Functions The following functions are used to retrieve or set the error code PACSDK Functions pac_GetLastError ErrHandling GetLastError r
200. odule is 8k local BYTE iSlot 1 int iDI TotalChz8 int TotalCh 8 DWORD Value DWORD IDO Value BOOL iRet pac ReadDIO O iSlot iDI TotalCh iDO TotalCh amp IDI Value amp IDO Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 239 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C pac_ReadDIO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI TotalChz8 int iDO TotalCh 8 DWORD Value DWORD IDO Value uart_Close hPort C 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 IDO Value PACNET UART Close hPort BOOL iRet pac ReadDlO hPort iSlot iDI TotalCh iDO TotalCh amp IDI Value amp IDO Value bool iRet PACNET IO ReadDIO hPort iSlot iDI TotalCh iDO TotalCh ref IDI Value ref PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 240 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com C pac_ReadDIO_MF 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 ref IDO Value PACNET UART Close hPort Remarks bo
201. off n bool err err PACNET IO WriteDO IntPtr Zero Convert ToInt32 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 PACNET ErrHandling GetLastError ToString n return PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 410 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks 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 0 Last Revised January 2013 Page 411 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 412
202. ol iRet PACNET IO ReadDIO MF hPort iSlot iDI TotalCh iDO TotalCh ref IDI Value 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 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 241 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 7 7 pac_ReadDIiLatch This function reads the DI latch value of the DI module Syntax C BOOL pac_ReadDILatch HANDLE hPort int slot int iDI TotalCh int iLatchType DWORD IDI Latch Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 242 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDI 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 0 latched low status IDI Latch Value out The pointer to the latch value read back from the DI module Return Value If the f
203. ole Application E Empty Project i Reporting EA Windows Service 4 WPF Custom Control Library Test es WEF User Control Library Windows Forms Control Library WCF Workflow My Templates E Other Languages Other Project Types EF Search Online Templates Test Projects A project for creating an application with a Windows Forms user interface NET Framework 3 5 Name WindowsFormsa pplication Location D ADoing Solution Neme WindowsFormsA pplication Create directory for solution PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 24 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add a button control to the Windows form 1 Open the form 2 Inthe Toolbox click the Button control and drag it to your form 3 Double click the button on the form to create a Click event Toolbox Office Ribbon Controls Excel Controls Dialog Editor All Windows Forms h Pointer Gy Background Worker 4 BindingNavigator ti BindingSource ab CheckBox CheckedListBox ColorDialog ComboBox ContextMenuStrip id DataGrid View is DataSet TE Date TimePicker 5 T B B Step 4 In order to use Dillmport you should add the namespace using Statement System Runtime InteropServices and then implement the function which you
204. om Control Library Test a WPF User Control Library g Windows Forms Control Library WCF Workflow My Templates E Other Languages e Other Project Types jJSearch Online Templates Test Projects A project for creating an application with a Windows Forms user interface NET Framework 3 0 Name Example Location D Doing v Create directory for solution Solution Name Example PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 28 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add the PACNET dll into the references of the project and then insert the code to complete your project 1 Click Project gt Add Reference 2 Choose PACNET dll from the list 3 Click OK to add the reference 4 Use the intelliSense feature to quickly select the function which you want to call Forml cs Fornics Design Start Page X a Solution Wi A x 4g WindowsFormsApplication2 For v Form Q sil ia Ie ELELA od Solution WindowsFormsA pplication2 cH WindowsFormsApplication2 H zd 3 using System using System Collections Generic using System ComponentModel using System Data Em 3 PACHET using System Drawing I D using System Text 43 memes using System Windows Forms C3 System Deployment 42 System Dra
205. on call GetLastError to obtain the last error ocde of Windows API PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 425 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 426 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 0 Last Revised January 2013 Page 427 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C TCHAR buf 1024 pac_GetCurrentDirectory buf 1024 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 428 Cop
206. otalCh uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iD TotalCh 8 BOOL iRet pac ClearDICNT 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 iDI TotalCh 8 BOOL iRet pac ClearDICNT MF hPort iSlot iChannel iDI TotalCh uart Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 261 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ClearDICNT f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDl_TotalCh 8 bool iRet PACNET IO ClearDICNT hPort iSlot iChannel iDI TotalCh PACNET UART Close hPort C pac_ClearDICNT_MF If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDI TotalChz8 bool iRet PACNET IO ClearDICNT MF hPort iSlot iChannel iDI 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 262 Copyright 20
207. owerOnValueAO This function reads the AO power on value of the AO module Syntax C BOOL pac_ReadModulePowerOnValueAO HANDLE hPort int slot int iChannel int TotalCh float fValue Parameters hPort in The serial port HANDLE opened by uart OpenY 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 329 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 ReadModulePowerOnValueAO hPort iSlot iChannel iAO_TotalCh amp fValue uart_Close hPort 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 R
208. plug in gt PACSDK vb dll gt pacsdk bas How to create a program with new SDK using Visual Basic 6 0 Step 1 Create a new project by using Visual Basic 6 0 New Project MetiveX EXE ActiveX DLL amen onto v 9 9 a ANO BS 2 B Wizard ActiveX Activex Manager Document DU Document Exe Cancel Don t show this dialog in the future PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 37 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Copy pacsdk bas and PACSDK vb dll to the application folder and Include pacsdk bas 1 Copy PACSDK bas and PACSDK vb dll to the application folder Click Project Add Module 3 Choose PACSDK bas from the list 4 Click OK to add the reference m Project Microsoft Yisual Basic design File Edit Vie ED ormat Debug Run Query Diagram Tools Add Ins Window Help 5 ER ine Gi fom Oo 0 y 1 oe S ES m df Add User Control 182151251 es Add Property Page Ta Add User Document Add WebClass Add Data Report Add DHTML Page Add Data Environment Add File Remove Forml FA References Components Project Properties Fg Projecti Microsoft Visual Basic design File Edit View Project Format Debug Run Query Diagram Tools Add Ins Window Help b n Ble o n SEES t 2 ER C S 214 te Project Projectl Project Formi Fo
209. ponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and 0 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 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 0 Last Revised January 2013 Page 220 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C pac_WriteDO Example 1 f 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 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 uart Close hPort Example 3 f the module is 8k remote int total channel 8 DWORD do value 4 turn on the channel two BOOL ret pac WriteDO 0 1 total channel do value BOOL ret pac WriteDO hPort PAC REMOTE 1 total channel do value BOOL ret pac WriteDO hPort 1 total channel do value PAC Standard API Manu
210. pt 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 On the XPAC the index of slot starts from 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 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 90 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 CIntrDlg OnButton2 pac EnableSlotInterrupt slot false disable slot interrupt pac UnregisterSlotInterrupt slot unregister slot interrupt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 91 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
211. r LENGTH PAC_MEM_SRAM CH uint address 0 the memory address where read from byte Buffer new byte 2 PACNET Memory ReadMemory address Buffer 2 0 Console WriteLine Buffer 0 Buffer 0 Buffer 1 Buffer 1 Console ReadLine The example displays the following output to the console Buffer 0 37 Buffer 1 38 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 written to the O Ox1FFF address of the EEPROM or the 0 Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 110 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 3 pac 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 0 Last Revised January 2013 Page 111 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters Address in Specifies the memory address where write from EEPROM 0 Ox1FFF
212. rDICNT pac ClearDICNT MF This function clears the counter value of the DI channel of the DI module Syntax C for pac ClearDICNT BOOL pac ClearDICNT HANDLE hPort int slot int iChannel int iD TotalCh C for pac ClearDICNT MF BOOL pac ClearDICNT MF HANDLE hPort int slot int iChannel int iD TotalCh E PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 259 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that the counter value belongs iDI TotalCh in Total number of the 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 0 Last Revised January 2013 Page 260 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ClearDICNT Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDI TotalCh 8 BOOL iRet pac_ClearDICNT hPort iSlot iChannel iDI_T
213. rName Console WriteLine The Module Name on slot 1 is strName Another directly returns the module name slot 2 strName PACNET Sys GetModuleName slot Console WriteLine The Module Name on slot 2 is strName Console ReadLine The example displays the following output to the console tf The Module Name on slot 1 is 87061 tf The Module Name on slot 2 is 8017H PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 47 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 2 pac GetRotaryID This function retrieves the position number of the rotary switch Syntax C int pac GetRotaryID 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 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 48 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int RotarylD RotaryID pac GetRotaryID CH int RotaryID RotaryID PACNET Sys GetRotaryID Console WriteLine The Rotary ID is RotaryID ToString Console ReadLine The example displays the following output to the console tf The Rotary ID is 0 PAC Standard API
214. rOnValueDO __ MF PAC IO WriteModulePowerOnValueDO PAC IO WriteModulePowerOnValueDO writes the DO power on values to DO modules pac_ReadModulePowerOnValueDO p ac_ReadModulePowerOnValueDO_M F PAC IO ReadModulePowerOnValueDO PAC IO ReadModulePowerOnValueDO reads the power on value of the DO modules pac_WriteModuleSafeValueAO PAC IO WriteModuleSafeValueAO writes the AO safe value to the AO modules pac_ReadModuleSafeValueAO PAC IO ReadModuleSafeValueAO reads the AO safe value of the AO module pac_WriteModulePowerOnValueAO PAC IO WriteModulePowerOnValueAO writes the AO power on value to the AO modules pac ReadModulePowerOnValueAO PAC IO ReadModulePowerOnValueAO reads the AO power on value of the AO module pac GetModuleLastOutputSource PAC IO GetModuleLastOutputSource reads the last output source of a module pac GetModuleWDTStatus PAC IO GetModuleWDTStatus reads the host watchdog status of a module pac GetModuleWDTConfig PAC IO GetModuleWDTConfig reads the host watchdog status of a module pac SetModuleWDTConfig PAC IO 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
215. rm PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 38 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com The following references illustrate how to develop the programs for XP 8000 and XP 8000 Atom step by step XP 8000 Refer to the chapter 4 on xp 8000 user manual for more details http ftp icpdas com pub cd xp 8000 document user manual XP 8000 Atom Refer to the chapter 5 on xp 8000 Atom user manual for more details http ftp icpdas com pub cd xpac atom document user manual PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 39 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 40 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 Last Revised January 2013 Page 41 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each o
216. rruptlnitialize 95 2 2 6 pac GetSlotInterruptEvent 97 2 2 7 pac SetSlotInterruptEvent 98 2 2 8 pac SetTriggerType 99 2 2 9 pac GetSlotInterruptID 100 2 2 10 pac InterruptDone 101 2 3 Memory Access 103 2 3 1 pac_GetMemorySize 106 2 3 2 pac ReadMemory 108 2 3 3 pac WriteMemory 111 2 3 4 pac EnableEEPROM 114 2 4 WatchOOe AP l eer NE 116 2 4 1 pac EnableWatchDog 119 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 4 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 5 Registry API 2 5 1 2 5 2 2 5 3 2 5 4 2 5 5 2 5 6 2 5 7 2 5 8 2 5 9 2 5 10 2 5 11 2 5 12 2 5 13 2 5 14 2 6 UART API 2 6 1 2 6 2 2 6 3 2 6 4 2 6 5 2 6 6 pac DisableWatchDog pac RefreshWatchDog pac GetWatchDogsState pac GetWatchDogTime pac SetWatchDogTime pac RegCountKey pac RegCountValue pac RegCreateKey pac RegDeleteKey pac RegDeleteValue pac RegGetDWORD pac RegGetKeyByIndex pac RegGetKeylInfo pac RegGetsString pac RegGetValueByIndex pac RegKeyExist pac RegSave pac RegSetsString pac RegSetDWORD uart Open uart Close uart SendExt uart Send uart RecvExt uart Recv PAC Standard API Manual v1 1 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Page 5 gt lt E mail service icpdas com 12
217. rt PACNET UART Open byte iSlot 1 int iValue 8 bool iRet PACNET IO ReadAIAlIHex hPort iSlot iValue PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 290 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 291 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 21 pac ReadCNT This function reads the counter values of the counter frequency modules Syntax C BOOL pac ReadCNT HANDLE hPort int slot int iChannel DWORD ICounter Value Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC REMOTE 0 255 iChannel in The channel that reads the counter value back from the counter frequency module ICounter Value out The pointer to the counter value that reads back from the counter frequency module PAC Standard API Manual v1 1
218. s in Specifies the retrigger value 07255 unit 10 microsecond 0 means disable retrigger function Return Value This function has does not return any 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 0 Last Revised January 2013 Page 84 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 Step 1 Set tigger type Program Start B pac_SetTriggerType Slot 1 0 Rising edge 1 Level trigger 2 Falling edge Step 2 Install user callback function pac RegisterSlotInterrupt Slot f Step 3 Set interrupt priority pac SetSlotInterruptPriority Slot Priority pe Step 4 Enable Interrupt p pac EnableSlotInterrupt Slot true int CALLBACK REO return PAC INTR DONE pac EnableSlotInterrupt gislot false pac UnregisterSlotInterrupt BYTE slot PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 85 Copyright 2013 ICP DAS Co Ltd All Righ
219. s chapter provides a guided tour that describes the steps needed to know download copy 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 XPAC series and PC PACSDK has replaced XPACSDK and DCON_PC ICP DAS has released a new SDK PACSDK which merged and replaced the XPACSDK and DCON_PC XPACSDK DCON PC b d PAC SDK The XPACSDK and DCON PC have been unified and renamed PACSDK The new PACSDK dll provides support x86 platforms for the XPAC series and PC PACSDK dll x86 is linked to C programs for the XPAC series to replace the previous SDK XPACSDK dll and for the PC to replace the previous SDK DCON PC dll The PACNET dll is used for Net CF programs C VB for both the XPAC series and PC to replace the previous SDKs XPacNet dll and DCON PC DotNet dll PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 15 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com New Previous SDK files comparison double check RIKA A Items XPACSDK Library DCON_PC Library PACSDKLibrary PACSDK h Development header files XPacSDK h DCON_Fun h PACSDK PWM h PACSDK lib Development library files XPacSDK lib DCON PC lib PACSDK PWM lib PACSDK dll Target device Native DLL files
220. s range is from 0 to 7 If remote the second Parameter need use the macro PAC REMOTE 10 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 309 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 lValue E C for pac WriteModulePowerOnValueDO MF BOOL pac WriteModulePowerOnValueDO MF HANDLE hPort int slot int TotalCh DWORD IValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 310 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDO TotalCh in The total number of DO channels of the DO modules iValue 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 0 denotes that the digital output channel is
221. se UART Close closes the COM port which has been opened uart_SendExt UART SendExt sends data as a string through the COM port which has been opened uart_Send UART Send sends data through the COM port which have been opened uart_RecvExt UART RecvExt receives a string OxOD A OxOD character is assigned to terminate the string uart Recv UART Recv retrieves data through the COM port which have been opened uart SendCmdExt UART SendCmdExt sends commands through the COM port which has been opened uart SetTimeOut UART SetTimeOut sets the time out timer uart EnableChecksum UART EnableCheckSum turns on the check sum or not uart SetTerminator UART SetTerminator sets the terminate characters uart BinSend UART BinSend sends out command string with or without null character under the consideration of the command length uart BinRecv UART BinRecv receives the response string data with or without null character under the consideration of receiving 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 0 Last Revised January 2013 Page 167 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com UART GetDataSize retrieves the n
222. se 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 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 339 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 35 pac SetModuleWDTConfig 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 0 Last Revised January 2013 Page 340 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 module is remote please use the macro 255 enStatus in 1 the host watchdog is enabled 0 the host watchdog is disabled watTimeout in The unit of return value is 100ms ifWDT_Overwrite only for i 8k in 1 the host watchdog does overwrite 0 the host watchdog does not overwrite Return Value If the function succeeds the return value is TRUE If the fun
223. served D lt E mail service icpdas com 2 5 7 pac RegGetKeyByIndex This function retrieves the name of specified index of registry key Syntax C BOOL pac RegGetKeyBylIndex LPCSTR KeyName DWORD dwindex LPSTR IpName y Parameters KeyName in Specific the path of registry key dwindex in Specific the index of registry key lpName out Assign a buffer to retrieves the specified key name 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret DWORD index 0 TCHAR strName 10 ret pac_RegGetKeyBylndex TEXT HKEY_USERS myKey index strName CH bool ret uint index 0 string strName new String 0 10 ret WinPAC RegGetKeyByIndex HKEY_USERS myKey index strName PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 147 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 8 pac RegGetKeylInfo This function retrieves the type of specified registry key Syntax
224. signStr 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret ret pac_RegSetString TEXT HKEY_USERS myKey value TEXT Hello exe 2 wcslen TEXT Hello exe sizeof TCHAR 2 CH bool ret ret WinPAC RegSetString HKEY_USERS myKey value Hello exe 2 uint Hello exe Length PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 159 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 y 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 PACERRO
225. t xix xix PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 117 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Watchdog Functions The following functions are used to retrieve or set the Watchdog PACSDK Functions pac EnableWatchDog PACNET Functions Sys WDT EnableWatchDog Description starts a watchdog operation pac DisableWatchDog Sys WDT DisableWatchDog stops a watchdog operation pac RefreshWatchDog Sys WDT RefreshWatchDog refreshes the watchdog pac_GetWatchDogState Sys WDT GetWatchDogState retrieves the watchdog state pac_GetWatchDogTime Sys WDT GetWatchDogTime retrieves the watchdog time pac_SetWatchDogTime Sys WDT SetWatchDogTime starts a watchdog operation PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 118 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt 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 0 Hardware watchdog PAC_WDT_HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PAC_WDT_OS value in Specifies the watchdog time Return Value If the function suc
226. t int iD TotalCh int TotalCh DWORD IDI Value DWORD IDO Value L PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 237 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iDI TotalCh in The total number of DI channels of the DIO module iDO 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 0 Last Revised January 2013 Page 238 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDIO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iD TotalCh 8 int iDO_TotalCh 8 DWORD Value DWORD IDO Value BOOL iRet pac_ReadDIO hPort iSlot iDI TotalCh iDO TotalCh amp IDI Value amp IDO Value uart_Close hPort Example 2 f the m
227. t address 0 byte Buffer new byte 2 OxAB OxCD int PAC_MEM_EEPROM 1 PACNET Memory EnableEEPROM true PACNET Memory WriteMemory address Buffer uint Buffer Length PAC MEM EEPROM PACNET Memory EnableEEPROM false Remarks Before writing EEPROM need turn on the EEPROM after writing EEPROM need turn off the EEPROM PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 115 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 Watchdog API Watchdog operations include basic management operations such as turning on and refreshing The following topics describe how you can operate watchdog programmatically by using the watchdog functions PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 116 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the Watchdog functions Functions Models pac_EnableWatchDog XP 8000 Y XP 8000 Atom Y PC pac DisableWatchDog pac RefreshWatchDog pac_GetWatchDogState pac_GetWatchDogTime pac_SetWatchDogTime Y Y Y Y Y lilii lt lt xix xix I lt lt lt lt xix lt lt lt lt lt lt lt j lt lt lt lt j lt lt lt lt lt j lt lt lt lt lt xix lt l
228. t x lt lt ix lt lt XR LX lt lt lt lt xx IRR XR XR LX lt x lt lt lt xx IRR XR lt lt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 132 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Registry Functions The following functions are used to retrieve or set the registry PACSDK Functions pac RegCountKey PAC Reg RegCountKey retrieves the specified registry key which has how many sub keys pac RegCountValue PAC Reg RegCountValue retrieves the specified registry key which has how many values pac RegCreateKey PAC Reg RegCreateKey creates the specified registry key pac RegDeleteKey PAC Reg RegDeleteKey deletes a named subkey from the specified registry key pac RegDeleteValue PAC Reg RegDeleteValue removes a named value from the specified registry key pac RegGetDWORD PAC Reg RegGetDWORD retrieves value of the specified registry key pac RegGetKeyByIndex PAC Reg RegGetKeyBylndex retrieves the name of specified index of registry key pac RegGetKeylInfo PAC_Reg RegGetKeyInfo retrieves the type of specified registry key pac RegGetsString PAC_Reg RegGetString retrieves the value of the specified registry key pac_RegGetValueBylndex PAC Reg RegGetValueByIndex retrieves the value of specifi
229. tal 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 0 Last Revised January 2013 Page 320 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 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 WriteModuleSafeValueAO hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort 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 5 bool iRet PACNET IO WriteModuleSafeValueAO hPort iSlot ichannel iAO_TotalCh fValue PACNET UART Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 321 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 to 7 If remote the second Parameter need use the macro 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 322 Copyright 2013
230. td All Rights Reserved D lt E mail service icpdas com 2 1 10 Pac_EnableLEDs PWR RUN LI L2 This function sets the state of the specified LED Syntax C void pac_EnableLEDs INT pin BOOL bFlag Parameters pin Specifies the user programmable LED 0 L1LED 1 L2LED bFlag Specifies the mode of the LED True Turn on the LED False Turn off the LED Return Value This function does not return any value Remark The function is only applied to the XP 8000 Atom series PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 66 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_EnableLEDs 0 TRUE CH Turn on the L1 LED PACNET Sys EnableLEDs 0 true Turn off the L2 LED PACNET Sys EnableLEDs 1 false PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 67 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 11 pac GetModuleType This function retrieves the type of I O modules which plugged into the XPAC series devices Syntax C int pac_GetModuleType BYTE slot Parameters slot in Specifies the slot number where the I O module is plugged into PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 68 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value For XPAC Ser
231. teValue TEXT HKEY USERSWmyKeyNvalue CH bool ret ret WinPAC RegDeleteValue TEXT HKEY_USERS myKey value Remarks The function could be used only in leaf key And in the function pac_RegDeleteKey can be used in any registry key except leaf key If you would delete a leaf key you should call pac RegDeleteValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 143 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 6 pac_RegGetDWORD This function retrieves value of the specified registry key Syntax C DWORD pac RegGetDWORD LPCSTR 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 0 Last Revised January 2013 Page 144 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C DWORD dwValue dwValue pac RegGetDWORD TEXT HKEY USERSWmyKeyWNvalue CH uint uValue uValue PACNET PAC_Reg RegGetDWORD HKEY_CURRENT_USER myKey value Console WriteLine The value of the specific key is uValue ToString Console ReadLine The example displays the following output to the console The value of the specific key is 1 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 145 Copyright 2013 ICP DAS Co Ltd All Rights Re
232. ters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AI value from the channel TotalCh in The total number of the Al channels of the Al module fValue 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 0 Last Revised January 2013 Page 272 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f 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 ReadAI 0 iSlot iChannel iAl_TotalCh amp fValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 273 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com CH f the module is 87k local IntP
233. th 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 0 Last Revised January 2013 Page 165 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 uart_Open Y Y Y Y Y Y Y Y uart_Close Y Y Y Y Y Y Y Y uart_SendExt Y Y Y Y Y Y Y Y uart_Send Y Y Y Y Y Y Y Y uart_RecvExt Y Y Y Y Y Y Y Y uart_Recv Y Y Y Y Y Y Y Y uart_SendCmdExt Y Y Y Y Y Y Y Y uart_SetTimeOut Y Y Y Y Y Y Y Y uart_EnableCheckSum Y Y Y Y Y Y Y Y uart_SetTerminator Y Y Y Y Y Y Y Y uart_BinSend Y Y Y Y Y Y Y Y uart_BinRecv Y Y Y Y Y Y Y Y uart_BinSendCmd Y Y Y Y Y Y Y Y uart_GetLineStatus Y Y Y Y Y Y Y Y uart_GetDataSize Y Y Y Y Y Y Y Y uart_SetLineStatus Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 166 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com UART Functions The following functions are used to retrieve or set the UART PACSDK Functions uart Open UART Open opens the COM port and specifies the baud rate parity bits data bits and stop bits uart Clo
234. 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 0 Last Revised January 2013 Page 395 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 If the function fails The return value is zero Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return 0 Interrupt done Set timer1 with 200 microsecond interval pac_SetBPTimerOut 200 300 TIMER PAC Standard API Manual v1 1 0 Last Revised J
235. tion 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 0 Last Revised January 2013 Page 198 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 199 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 COMA4 9600 N 8 1
236. tr 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 0 to 7 If remote the second Parameter need use the macro PAC REMOTE IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 274 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 16 pac_ReadAlHex This function reads the 2 s complement mode Al value of the Al module Syntax C BOOL pac_ReadAlHex HANDLE hPort int slot int iChannel int TotalCh int iValue PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 275 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 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 module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AI value from the channel TotalCh in The total number of the Al channels of the Al module iValue in The pointer to the A
237. ts Reserved D lt 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 5xxx VP 25Wx pac RegisterSlotInterrupt Y Y Y Y Y Y Y Y pac UnregisterSlotInterrupt Y Y Y Y Y Y Y Y pac EnableSlotInterrupt Y Y Y Y Y Y Y Y pac SetSlotInterruptPriority Y Y Y Y Y Y Y Y pac Interruptlnitialize Y Y Y Y Y Y Y Y pac GetSlotInterruptEvent Y Y Y Y Y Y Y Y pac SetSlotInterruptEvent Y Y Y Y Y Y Y Y pac SetTriggerType Y Y Y Y Y Y Y Y pac GetSlotInterruptiD Y Y Y Y Y Y Y Y pac InterruptDone Y Y Y Y Y Y Y Y PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 86 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Interrupt Functions The following functions are used to retrieve or set the slot interrupt PACSDK Functions pac_RegisterSlotInterrupt PACNET Functions Interrupt RegisterSlotInterrupt Description registers the slot interrupt service route after turning on the slot interrupt pac_UnregisterSlotInterrupt Interrupt UnregisterSlotInterrupt unregisters slot interrupt service route and disables a hardware interrupt as specified by its interrupt identifier pac EnableSlotInterrupt Interrupt EnableSlotInterrupt performs hardware operations necessary to enable the specif
238. ts Reserved D lt 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 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannelz2 long Icnt 1 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 long Icnt 1 PACNET UART Close hPort BOOL iRet pac SetPWMPulseCount hPort iSlot iChannel lcnt bool iRet PACNET PWM SetPWMPulseCount hPort iSlot iChannel lcnt PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 385 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 16 pac GetPWMpPulseCount This function reads the PWM step value for a specific channel Syntax C bool pac GetPWMPulseCount HANDLE port int slot short chlndex 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 module is remote please use the macro PAC REMOTE 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 disable
239. turn value is FLASE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 unsigned char pwm 32 unsigned char di 32 uart_Close hPort CH IntPtr hPort hPort PACNET UART Open byte iSlot 1 byte pwm new byte 32 byte di new byte 32 PACNET UART Close hPort BOOL iRet pac GetPWMDlIOStatus hPort iSlot pwm di bool iRet PACNET PWM GetPWMbDIOStatus hPort iSlot ref pwm ref di PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 383 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com 2 8 15 pac_SetPWMPulseCount This function sets the PWM step value for a specific channel Syntax C bool pac SetPWMPulseCount HANDLE port int slot short chlndex 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 module is remote please use the macro PAC REMOTE 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 0 Last Revised January 2013 Page 384 Copyright 2013 ICP DAS Co Ltd All Righ
240. uary 2013 Page 34 gt lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 Inthe Project Type column choose Other Languages gt Visual Basic gt Windows In the Template column choose Windows Forms Application 2 3 Name your project 4 Click OK to create your new project Hew Project Project types Templates Framework 3 5 aB Visual C Other Languages Visual Basic Windows Web Smart Device Office Database Reporting Test WCF Workflow Visual C Other Project Types Test Projects Visual Studio installed templates Windows Forms Application 43 WPF Application EA Console Application Fe Windows Service 58 WPF User Control Library My Templates L E Search Online Templates xs Class Library mg WPF Browser Application Empty Project ee WPF Custom Control Library fe Windows Forms Control Library project for creating an application with a Windows user interface NET Framework 3 5 Name Example Location DADoing Solution Name Example PAC Standard API Manual v1 1 0 v Gem Create directory for solution Last Revised January 2013 Page 35 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add the PACNET dll into the references of the project and then insert the
241. uary 2013 Page 19 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 1 C C based on Visual Studio 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 PC application or plug in gt PACSDK h gt PACSDK 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 Wiew Tool Test Window Help Hew ko Project Shit Open Web Site Shift AEN Close File Cty Project From Existing Code f Save all Ctr Shits Recent Files Recent Projects Exit Step 2 Select Windows Forms Application PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 20 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com New Project Project types 5 Visual Visual Studio installed templates Other Languages H Visual Basic Chess Library E Visual C Templates NET Framework 3 5 ATL CLR General MFC aa Smart Device a Windows Service Test Win32 Other Project Types Test Projects X Search Online Templates My Templates A project for creating an application with a Windows user interface Name Enter name Location D Doing Solution Name
242. ue uart_Close hPort PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 235 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDI f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 int iDl TotalCh 8 uint IDI Value PACNET UART Close hPort CH pac ReadDI MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 int iDI TotalCh 8 uint IDI Value PACNET UART Close hPort Remarks bool iRet PACNET IO ReadDl hPort iSlot iDI TotalCh ref IDI Value bool iRet PACNET IO ReadDI MF hPort iSlot iDI TotalCh ref IDI Value 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 255 which range is from 0 to 255 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 236 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 TotalCh DWORD IDI_ Value DWORD IDO_ Value C for pac_ReadDIO_MF BOOL pac ReadDIO MF HANDLE hPort int slo
243. umber of bytes received by the serial provider but not yet read by a uart_Recv uart_GetDataSize i 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 0 Last Revised January 2013 Page 168 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 1 uart Open This function opens the COM port and specifies the baud rate parity bits data bits and stop bits Syntax C HANDLE uart_Open LPCSTR ConnectionString PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 169 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 COM2 WinPAC COMO COM 1 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 78 Stop bits 1 ONESTOPBIT 2 TWOSTOPBITS 1 5 ONESSTOPBITS PAC Standard API Manual v1 1 0 Last Revised
244. unction succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 243 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI TotalCh 8 int iLatchType 0 DWORD IDI Latch Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iDI TotalChz8 int iLatchType 0 DWORD Latch Value BOOL iRet pac ReadDlLatch hPort iSlot iDI TotalCh iLatchType amp IDI Latch Value BOOL iRet pac ReadDlLatch 0 iSlot iDI TotalCh iLatchType amp IDI Latch Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 244 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt 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 iLatchType 0 uint IDI Latch Value IDI Latch Value PACNET UART Close hPort Remarks bool iRet PACNET IO ReadDILatch hPort iSlot iDl TotalCh iLatchType ref 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 255 which range
245. urn a value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 52 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char SDK 32 pac_GetSDKVersion SDK CH n net ths API is different with VC And there are two API pac_GetPacSDKVersion and pac_GetPacNetVersion string PacSDK string PacNET PacSDK PACNET Sys GetPacSDKVersion retrieving PacSDK version PacNET PACNET Sys GetPacNetVersion retrieving PacNET version Console WriteLine The PacSDK dll version is PacSDK Console WriteLine The PacNET dll version is PacNET Console ReadLine The example displays the following output to the console The PacSDK dll version is 4 2 3 6 The PacNET dll version is 2 1 0 3 PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 53 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 5 pac_ChangeSlot This function handles the slot of the XPAC 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 return a value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 54 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BYTE slot
246. want to call Demonstrate an example of using pac writeDO in NET project The function defined in PACSDK h file PAC API BOOL pac WriteDO HANDLE hPort int slot int iDO TotalCh DWORD IDO Value PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 25 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com How to use in your NET project 1 Added this line in your project i H Ls DIlImport PACSDK dll EntryPoint pac WriteDO i public extern static bool pac WriteDO IntPtr hPort int slot int iDO_TotalCh i uint IDO Value I a ELL ED ES E N A E EDEN 3 Then you can use this function pac WriteDO in your NET project Code Snippet a a EET ea PO E RN Nen or using System Windows Forms using System Runtime InteropServices I I I I I I I I I I I I Namespace I I t i public partial class Form1 Form I I i i Dllimport PACSDK dll EntryPoint pac WriteDO i I public extern static bool pac WriteDO IntPtr hPort int slot int iDO TotalCh uint IDO Value i i I I I public Form1 I i I i InitializeComponent i I I private void button1 Click object sender EventArgs e I I 1 pac WriteDO IntPtr 1 1 16 Oxff I I i I I m j PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 26 Copyright 2013 ICP DAS Co Ltd All Rights Reserved
247. watchdog is second In addition the value cannot be zero The value of the parameter value for hardware watchdog is limited to the range of 0763 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds Syntax C BOOL pac_SetWatchDogTime int wdt DWORD value Parameters wat in Specifies the Watchdog type 0 Hardware watchdog PAC_WDT_HW In XPAC WES series devices the hardware watchdog can not be used or the system will be damaged 1 OS watchdog PAC WDT OS value in Specifies the watchdog time PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 129 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value This function does not return any value Examples C DWORD dwTime 1000 pac_SetWatchDogTime PAC_WDT_OS dwTime CH Set the OS watchdog time 10 seconds uint uTime 10 int PAC_WDT_OS 1 Remarks The same as the pac_EnableWatchDog function PACNET Sys WDT SetWatchDogTime PAC WDT OS uTime The unit of the parameter value for OS watchdog is second In addition the value cannot be zero for XPAC series only The value of the parameter value for hardware watchdog is limited to the range of 0763 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds PAC Standar
248. wing namespace WindowsFormsApplication2 42 System Windows Forms 2 System Xml public partial class Form1 Form H EE Forml c Program cs E public lass PACKET BP Timer ag PAC CALLBACK FUNC g PAC IO PAC Reg amp PWM You can add the the namespace using PACNET to your code and it can simplify object names Such as PAC IO GetBit instead of PACNET PAC IO GetBit PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 29 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 3 VB net Required library files The following DLL files are needed to include for developing a XPAC PC application or plug in gt PACSDK dIl 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 Tools Test Window Help Hew H Piet Chir Shitten Open Web Site Shit Alt Close File Project From Existing Code il Save All Chlrshiftes Recent Files Recent Projects Exit PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 30 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 Inthe Project Type column choose Other Languages gt Visual
249. yright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 ctoType in Specifies the time out timer type as following 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 0 Last Revised January 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Page 187 gt lt E mail service icpdas com Examples C HANDLE hOpen DWORD mes hOpen uart_Open COM1 9600 N 8 1 mes 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 0 PACNET UART Close hOpen PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 188 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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_
250. yright 2013 ICP DAS Co Ltd All Rights Reserved D lt 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 0x00001 Unknow Error 0x10001 Slot registered error 0x10002 Slot not registered error 0x10003 Unknown Module 0x10004 Module doesn t exist 0x10005 Invalid COM port number 0x10006 Function not supported 0x10007 Module doesn t exist 0x10008 Slot not registered error 0x11001 EEPROM accesses invalid address 0x11002 SRAM accesses invalid address 0x11003 SRAM accesses invalid type 0x11004 NVRAM accesses invalid address 0x11005 EEPROM write protection 0x11006 EEPROM write fail 0x11007 EEPROM read fail 0x12001 The input value is invalid 0x12002 The wdt doesn t exist 0x12003 The wdt init error 0x13001 Create interrupt s event failure 0x14001 Uart check sum error 0x14002 Uart read timeout 0x14003 Uart response error 0x14004 Uart under input range 0x14005 Uart exceed input range 0x14006 Uart open filed 0x14007 Uart get Comm Modem status error 0x14008 Uart get wrong line status PAC Standard API Manual v1 1 0 Last Revised January 2013 Page 429 Copyright 2013 ICP DAS Co Ltd All Rights Reserved

Download Pdf Manuals

image

Related Search

Related Contents

Q5K-YSK-060-K02  ATEUS ® - GSM GATE ISDN  CU-GSM central unit  APC 17" Keyboard Drawer Beige  Marmitek Invisible Scart 300  

Copyright © All rights reserved.
Failed to retrieve file