Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

ldcncom.h

By: a guest on Dec 4th, 2012  |  syntax: C++  |  size: 2.58 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //---------------------------------------------------------------------------
  2. #include "sio_util.h"
  3. //---------------------------------------------------------------------------
  4. typedef unsigned char byte;
  5.  
  6. typedef struct _LDCNMOD {
  7.         byte    modtype;        //module type
  8.         byte    modver;         //module version number
  9.         byte    statusitems;    //definition of items to be returned
  10.         byte    stat;           //status byte
  11.         byte    groupaddr;      //current group address
  12.         bool    groupleader;    //TRUE if group leader
  13.         void *  p;              //pointer to specific module's data structure
  14. } LDCNMOD;
  15.  
  16.  
  17. #define MAXSIOERROR 3
  18.  
  19. //Define PIC baud rate divisors
  20. #define PB9600         129
  21. #define PB19200         63
  22. #define PB57600         20
  23. #define PB115200        10
  24.  
  25. //Module type definitions:
  26. #define SERVOMODTYPE    0
  27. #define SERVOHYBTYPE   90
  28. #define IOMODTYPE       2
  29. #define STEPMODTYPE     3
  30.  
  31. //The following must be created for each new module type:
  32. //              data structure XXXMOD
  33. //              Initializer function NewXXXMod
  34. //              Status reading function GetXXXStat
  35. //              LdcnInit and SendLdcnCmd must be modified to include calls
  36. //                      to the two functions above
  37.  
  38. #define CKSUM_ERROR     0x02    //Checksum error bit in status byte
  39.  
  40. #define MAXNUMMOD       33
  41.  
  42.  
  43. //Initialization and shutdown
  44. void InitVars(void);
  45. void LdcnSetStopCtrl(byte addr, byte mode);
  46.  
  47. DLLENTRY(int)  LdcnInit(char *portname, unsigned int baudrate);
  48. DLLENTRY(int)  LdcnFullInit(char *portname, unsigned int baudrate);
  49. DLLENTRY(int)  LdcnRestoreNetwork(char *portname, unsigned int baudrate);
  50. DLLENTRY(BOOL) LdcnSendCmd(byte addr, byte cmd, char *datastr, byte n);
  51. DLLENTRY(void) FixSioError();
  52. DLLENTRY(void) LdcnShutdown(void);
  53.  
  54. //Module type independant commands (supported by all module types)
  55. DLLENTRY(BOOL) LdcnSetGroupAddr(byte addr, byte groupaddr, bool leader);
  56. DLLENTRY(BOOL) LdcnDefineStatus(byte addr, byte statusitems);
  57. DLLENTRY(BOOL) LdcnReadStatus(byte addr, byte statusitems);
  58. DLLENTRY(BOOL) LdcnChangeBaud(byte groupaddr, unsigned int baudrate);
  59. DLLENTRY(BOOL) LdcnSynchInput(byte groupaddr);
  60. DLLENTRY(BOOL) LdcnNoOp(byte addr);
  61. DLLENTRY(BOOL) LdcnHardReset();
  62. DLLENTRY(BOOL) LdcnResetDevice(byte addr);
  63.  
  64. //Retrieve module type independant data from a module's data structure
  65. DLLENTRY(byte) LdcnGetStat     (byte addr);
  66. DLLENTRY(byte) LdcnGetStatItems(byte addr);
  67. DLLENTRY(byte) LdcnGetModType  (byte addr);
  68. DLLENTRY(byte) LdcnGetModVer   (byte addr);
  69. DLLENTRY(byte) LdcnGetGroupAddr(byte addr);
  70. DLLENTRY(BOOL) LdcnGroupLeader (byte addr);
  71.  
  72. DLLENTRY(HANDLE) GetComPort();
  73. DLLENTRY(int)    GetSioError();
  74. DLLENTRY(int)    IsBusy();
clone this paste RAW Paste Data