examples/win32test/win32test.c
author Edouard Tisserant
Fri, 27 Nov 2015 16:27:46 +0100
changeset 795 8dc7a42d38b1
parent 701 9e4ccb3cab96
permissions -rw-r--r--
fixed static link of can driver
701
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     1
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     2
/* File generated by gen_cfile.py. Should not be modified. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     3
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     4
#include "win32test.h"
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     5
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     6
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     7
/* Declaration of mapped variables                                        */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     8
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
     9
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    10
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    11
/* Declaration of value range types                                       */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    12
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    13
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    14
#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    15
UNS32 win32test_valueRangeTest (UNS8 typeValue, void * value)
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    16
{
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    17
  switch (typeValue) {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    18
    case valueRange_EMC:
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    19
      if (*(UNS8*)value != (UNS8)0) return OD_VALUE_RANGE_EXCEEDED;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    20
      break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    21
  }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    22
  return 0;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    23
}
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    24
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    25
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    26
/* The node id                                                            */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    27
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    28
/* node_id default value.*/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    29
UNS8 win32test_bDeviceNodeId = 0x00;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    30
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    31
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    32
/* Array of message processing information */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    33
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    34
const UNS8 win32test_iam_a_slave = 0;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    35
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    36
TIMER_HANDLE win32test_heartBeatTimers[1];
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    37
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    38
/*
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    39
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    40
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    41
                               OBJECT DICTIONARY
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    42
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    43
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    44
*/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    45
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    46
/* index 0x1000 :   Device Type. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    47
                    UNS32 win32test_obj1000 = 0x12D;	/* 301 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    48
                    subindex win32test_Index1000[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    49
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    50
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1000 }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    51
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    52
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    53
/* index 0x1001 :   Error Register. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    54
                    UNS8 win32test_obj1001 = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    55
                    subindex win32test_Index1001[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    56
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    57
                       { RO, uint8, sizeof (UNS8), (void*)&win32test_obj1001 }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    58
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    59
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    60
/* index 0x1003 :   Pre-defined Error Field */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    61
                    UNS8 win32test_highestSubIndex_obj1003 = 0; /* number of subindex - 1*/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    62
                    UNS32 win32test_obj1003[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    63
                    {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    64
                      0x0	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    65
                    };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    66
                    ODCallback_t win32test_Index1003_callbacks[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    67
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    68
                       NULL,
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    69
                       NULL,
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    70
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    71
                    subindex win32test_Index1003[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    72
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    73
                       { RW, valueRange_EMC, sizeof (UNS8), (void*)&win32test_highestSubIndex_obj1003 },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    74
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1003[0] }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    75
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    76
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    77
/* index 0x1005 :   SYNC COB ID. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    78
                    UNS32 win32test_obj1005 = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    79
                    ODCallback_t win32test_Index1005_callbacks[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    80
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    81
                       NULL,
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    82
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    83
                    subindex win32test_Index1005[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    84
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    85
                       { RW, uint32, sizeof (UNS32), (void*)&win32test_obj1005 }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    86
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    87
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    88
/* index 0x1006 :   Communication / Cycle Period */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    89
                    UNS32 win32test_obj1006 = 0x0;   /* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    90
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    91
/* index 0x1014 :   Emergency COB ID */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    92
                    UNS32 win32test_obj1014 = 0x80 + 0x00;   /* 128 + NodeID */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    93
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    94
/* index 0x1016 :   Consumer Heartbeat Time */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    95
                    UNS8 win32test_highestSubIndex_obj1016 = 0;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    96
                    UNS32 win32test_obj1016[]={0};
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    97
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    98
/* index 0x1017 :   Producer Heartbeat Time */ 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
    99
                    UNS16 win32test_obj1017 = 0x0;   /* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   100
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   101
/* index 0x1018 :   Identity. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   102
                    UNS8 win32test_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   103
                    UNS32 win32test_obj1018_Vendor_ID = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   104
                    UNS32 win32test_obj1018_Product_Code = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   105
                    UNS32 win32test_obj1018_Revision_Number = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   106
                    UNS32 win32test_obj1018_Serial_Number = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   107
                    subindex win32test_Index1018[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   108
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   109
                       { RO, uint8, sizeof (UNS8), (void*)&win32test_highestSubIndex_obj1018 },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   110
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1018_Vendor_ID },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   111
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1018_Product_Code },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   112
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1018_Revision_Number },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   113
                       { RO, uint32, sizeof (UNS32), (void*)&win32test_obj1018_Serial_Number }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   114
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   115
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   116
/* index 0x1280 :   Client SDO 1 Parameter. */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   117
                    UNS8 win32test_highestSubIndex_obj1280 = 3; /* number of subindex - 1*/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   118
                    UNS32 win32test_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   119
                    UNS32 win32test_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   120
                    UNS8 win32test_obj1280_Node_ID_of_the_SDO_Server = 0x0;	/* 0 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   121
                    subindex win32test_Index1280[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   122
                     {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   123
                       { RO, uint8, sizeof (UNS8), (void*)&win32test_highestSubIndex_obj1280 },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   124
                       { RW, uint32, sizeof (UNS32), (void*)&win32test_obj1280_COB_ID_Client_to_Server_Transmit_SDO },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   125
                       { RW, uint32, sizeof (UNS32), (void*)&win32test_obj1280_COB_ID_Server_to_Client_Receive_SDO },
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   126
                       { RW, uint8, sizeof (UNS8), (void*)&win32test_obj1280_Node_ID_of_the_SDO_Server }
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   127
                     };
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   128
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   129
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   130
/* Declaration of pointed variables                                       */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   131
/**************************************************************************/
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   132
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   133
const indextable win32test_objdict[] = 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   134
{
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   135
  { (subindex*)win32test_Index1000,sizeof(win32test_Index1000)/sizeof(win32test_Index1000[0]), 0x1000},
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   136
  { (subindex*)win32test_Index1001,sizeof(win32test_Index1001)/sizeof(win32test_Index1001[0]), 0x1001},
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   137
  { (subindex*)win32test_Index1005,sizeof(win32test_Index1005)/sizeof(win32test_Index1005[0]), 0x1005},
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   138
  { (subindex*)win32test_Index1018,sizeof(win32test_Index1018)/sizeof(win32test_Index1018[0]), 0x1018},
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   139
  { (subindex*)win32test_Index1280,sizeof(win32test_Index1280)/sizeof(win32test_Index1280[0]), 0x1280},
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   140
};
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   141
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   142
const indextable * win32test_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks)
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   143
{
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   144
	int i;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   145
	*callbacks = NULL;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   146
	switch(wIndex){
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   147
		case 0x1000: i = 0;break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   148
		case 0x1001: i = 1;break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   149
		case 0x1005: i = 2;*callbacks = win32test_Index1005_callbacks; break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   150
		case 0x1018: i = 3;break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   151
		case 0x1280: i = 4;break;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   152
		default:
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   153
			*errorCode = OD_NO_SUCH_OBJECT;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   154
			return NULL;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   155
	}
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   156
	*errorCode = OD_SUCCESSFUL;
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   157
	return &win32test_objdict[i];
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   158
}
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   159
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   160
/* 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   161
 * To count at which received SYNC a PDO must be sent.
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   162
 * Even if no pdoTransmit are defined, at least one entry is computed
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   163
 * for compilations issues.
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   164
 */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   165
s_PDO_status win32test_PDO_status[1] = {s_PDO_status_Initializer};
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   166
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   167
const quick_index win32test_firstIndex = {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   168
  0, /* SDO_SVR */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   169
  4, /* SDO_CLT */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   170
  0, /* PDO_RCV */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   171
  0, /* PDO_RCV_MAP */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   172
  0, /* PDO_TRS */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   173
  0 /* PDO_TRS_MAP */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   174
};
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   175
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   176
const quick_index win32test_lastIndex = {
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   177
  0, /* SDO_SVR */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   178
  4, /* SDO_CLT */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   179
  0, /* PDO_RCV */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   180
  0, /* PDO_RCV_MAP */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   181
  0, /* PDO_TRS */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   182
  0 /* PDO_TRS_MAP */
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   183
};
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   184
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   185
const UNS16 win32test_ObjdictSize = sizeof(win32test_objdict)/sizeof(win32test_objdict[0]); 
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   186
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   187
CO_Data win32test_Data = CANOPEN_NODE_DATA_INITIALIZER(win32test);
Christian Taedcke <hacking@taedcke.com>
parents: 369
diff changeset
   188