Subversion Repositories HomeAutomation

Rev

Rev 1730 | Rev 1754 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. #include "sns_irTransceive.h"
  3.  
  4. #if IR_RX_ENABLE==1
  5. struct {
  6.     uint8_t             state;
  7.     uint16_t            *rxbuf;
  8.     uint8_t             rxlen;
  9.     uint8_t             timerNum;
  10.     Ir_Protocol_Data_t  proto;
  11.     uint8_t             newData;
  12. } irRxChannel[IR_SUPPORTED_NUM_CHANNELS];
  13. #endif
  14.  
  15. #if IR_TX_ENABLE==1
  16. struct {
  17.     uint8_t             state;
  18.     uint16_t            *txbuf;
  19.     uint8_t             txlen;
  20.     uint8_t             timerNum;
  21.     uint8_t             repeatCount;
  22.     Ir_Protocol_Data_t  proto;
  23.     uint8_t             stopSend;
  24.     uint8_t             sendComplete;
  25. } irTxChannel[IR_SUPPORTED_NUM_CHANNELS];
  26. #endif
  27.  
  28. uint16_t    buf[3][MAX_NR_TIMES];
  29.  
  30. StdCan_Msg_t        irTxMsg;
  31.  
  32. #if (sns_irTransceive_SEND_DEBUG==1)
  33. void send_debug(uint16_t *buffer, uint8_t len) {
  34.     StdCan_Msg_t dbgIrTxMsg;
  35.     /* the protocol is unknown so the raw ir-data is sent, makes it easier to develop a new protocol */
  36.  
  37.     StdCan_Set_class(dbgIrTxMsg.Header, CAN_MODULE_CLASS_SNS);
  38.     StdCan_Set_direction(dbgIrTxMsg.Header, DIRECTIONFLAG_FROM_OWNER);
  39.     dbgIrTxMsg.Length = 8;
  40.     dbgIrTxMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE;
  41.     dbgIrTxMsg.Header.ModuleId = sns_irTransceive_ID;
  42.     dbgIrTxMsg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRRAW;
  43.     for (uint8_t i = 0; i < len>>2; i++) {
  44.         uint8_t index = i<<2;
  45.  
  46.         dbgIrTxMsg.Data[0] = (buffer[index]>>8)&0xff;
  47.         dbgIrTxMsg.Data[1] = (buffer[index]>>0)&0xff;
  48.         dbgIrTxMsg.Data[2] = (buffer[index+1]>>8)&0xff;
  49.         dbgIrTxMsg.Data[3] = (buffer[index+1]>>0)&0xff;
  50.         dbgIrTxMsg.Data[4] = (buffer[index+2]>>8)&0xff;
  51.         dbgIrTxMsg.Data[5] = (buffer[index+2]>>0)&0xff;
  52.         dbgIrTxMsg.Data[6] = (buffer[index+3]>>8)&0xff;
  53.         dbgIrTxMsg.Data[7] = (buffer[index+3]>>0)&0xff;
  54.                
  55.         /* buffers will be filled when sending more than 2-3 messages, so retry until sent */
  56.         while (StdCan_Put(&dbgIrTxMsg) != StdCan_Ret_OK) {}
  57.         _delay_ms(1);
  58.     }
  59.    
  60.     uint8_t lastpacketcnt = len&0x03;
  61.     if (lastpacketcnt > 0) {
  62.         dbgIrTxMsg.Length = lastpacketcnt<<1;
  63.         for (uint8_t i = 0; i < lastpacketcnt; i++) {
  64.             dbgIrTxMsg.Data[i<<1] = (buffer[(len&0xfc)|i]>>8)&0xff;
  65.             dbgIrTxMsg.Data[(i<<1)+1] = (buffer[(len&0xfc)|i]>>0)&0xff;
  66.         }
  67.         /* buffers will be filled when sending more than 2-3 messages, so retry until sent */
  68.         while (StdCan_Put(&dbgIrTxMsg) != StdCan_Ret_OK) {}
  69.         _delay_ms(1);
  70.     }
  71.  
  72. }
  73. #endif
  74.  
  75. #if IR_RX_ENABLE==1
  76. void sns_irTransceive_RX_done_callback(uint8_t channel, uint16_t *buffer, uint8_t len)
  77. {
  78.     if (channel < IR_SUPPORTED_NUM_CHANNELS)
  79.     {
  80.         irRxChannel[channel].newData = TRUE;
  81.         irRxChannel[channel].rxlen = len;
  82.     }
  83. }
  84. #endif
  85.  
  86. #if IR_TX_ENABLE==1
  87. void sns_irTransceive_TX_done_callback(uint8_t channel)
  88. {
  89.     if (channel < IR_SUPPORTED_NUM_CHANNELS)
  90.     {
  91.         irTxChannel[channel].sendComplete = TRUE;
  92.     }
  93. }
  94. #endif
  95.  
  96. void sns_irTransceive_Init(void)
  97. {
  98. /* Debug IO, PB7 */
  99. gpio_set_out(EXP_A);
  100. gpio_set_pin(EXP_A);
  101.  
  102.     StdCan_Set_class(irTxMsg.Header, CAN_MODULE_CLASS_SNS);
  103.     StdCan_Set_direction(irTxMsg.Header, DIRECTIONFLAG_FROM_OWNER);
  104.     irTxMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE;
  105.     irTxMsg.Header.ModuleId = sns_irTransceive_ID;
  106.     irTxMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_IR;
  107.     irTxMsg.Length = 6;
  108.  
  109.     for (uint8_t i = 0; i < IR_SUPPORTED_NUM_CHANNELS; i++)
  110.     {
  111. #if IR_RX_ENABLE==1
  112.         irRxChannel[i].state = sns_irTransceive_STATE_DISABLED;
  113.         irRxChannel[i].newData = FALSE;
  114.         irRxChannel[i].rxlen = 0;
  115.         irRxChannel[i].proto.timeout=0;
  116.         irRxChannel[i].proto.data=0;
  117.         irRxChannel[i].proto.repeats=0;
  118.         irRxChannel[i].proto.protocol=0;
  119. #endif
  120.  
  121. #if IR_TX_ENABLE==1
  122.         irTxChannel[i].state = sns_irTransceive_STATE_DISABLED;
  123.         irTxChannel[i].sendComplete = FALSE;
  124.         irTxChannel[i].repeatCount = 0;
  125.         irTxChannel[i].txlen = 0;
  126.         irTxChannel[i].proto.data=0;
  127.         irTxChannel[i].proto.repeats=0;
  128.         irTxChannel[i].proto.framecnt=0;
  129.         irTxChannel[i].proto.protocol=0;
  130. #endif
  131.     }
  132.    
  133. #if IR_RX_ENABLE==1
  134.     irRxChannel[0].timerNum=sns_irTransceive_RX0_REPEATE_TIMER;
  135.     irRxChannel[1].timerNum=sns_irTransceive_RX1_REPEATE_TIMER;
  136.     irRxChannel[2].timerNum=sns_irTransceive_RX2_REPEATE_TIMER;
  137. #endif
  138.  
  139. #if IR_TX_ENABLE==1
  140.     irTxChannel[0].timerNum=sns_irTransceive_TX0_REPEATE_TIMER;
  141.     irTxChannel[1].timerNum=sns_irTransceive_TX1_REPEATE_TIMER;
  142.     irTxChannel[2].timerNum=sns_irTransceive_TX2_REPEATE_TIMER;
  143. #endif
  144.    
  145.     IrTransceiver_Init();
  146.     /* Configure all TX VCC pins as outputs and disable them */
  147.     gpio_set_out(sns_irTransceive_VCC_EN0_PIN);
  148.     gpio_set_out(sns_irTransceive_VCC_EN1_PIN);
  149.     gpio_set_out(sns_irTransceive_VCC_EN2_PIN);
  150.     gpio_set_pin(sns_irTransceive_VCC_EN0_PIN);
  151.     gpio_set_pin(sns_irTransceive_VCC_EN1_PIN);
  152.     gpio_set_pin(sns_irTransceive_VCC_EN2_PIN);
  153.  
  154. #if IR_TX_ENABLE==1
  155.     gpio_set_out(sns_irTransceive_MOD_PIN);
  156.     gpio_set_out(sns_irTransceive_TX0_PIN);
  157.     gpio_set_out(sns_irTransceive_TX1_PIN);
  158.     gpio_set_out(sns_irTransceive_TX2_PIN);
  159. #if IR_TX_ACTIVE_LOW==1
  160.     gpio_set_pin(sns_irTransceive_TX0_PIN);
  161.     gpio_set_pin(sns_irTransceive_TX1_PIN);
  162.     gpio_set_pin(sns_irTransceive_TX2_PIN);
  163. #endif
  164. #endif
  165.  
  166. }
  167.  
  168. void sns_irTransceive_Process(void)
  169. {
  170.     for (uint8_t channel=0; channel < IR_SUPPORTED_NUM_CHANNELS; channel++)
  171.     {
  172. //gpio_toggle_pin(EXP_A); /* Toggle debug output PB7 */
  173.  
  174. #if IR_RX_ENABLE==1
  175.         switch (irRxChannel[channel].state)
  176.         {
  177.         case sns_irTransceive_STATE_IDLE:
  178.             irRxChannel[channel].state = sns_irTransceive_STATE_START_RECEIVE;
  179.             break;
  180.  
  181.         case sns_irTransceive_STATE_START_RECEIVE:
  182.             IrTransceiver_ResetRx(channel);
  183.             cli();
  184.             irRxChannel[channel].newData = FALSE;
  185.             sei();
  186.             irRxChannel[channel].state = sns_irTransceive_STATE_RECEIVING;
  187.             break;
  188.        
  189.         case sns_irTransceive_STATE_RECEIVING:
  190.             if (irRxChannel[channel].newData == TRUE) {
  191.                 //TODO: move this line to the RX callback
  192.                 IrTransceiver_DisableRx(channel);
  193.                 cli();
  194.                 irRxChannel[channel].newData = FALSE;
  195.                 sei();
  196.  
  197.                 /* Let protocol driver parse and then send on CAN */
  198.                 uint8_t res2 = parseProtocol(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen, &irRxChannel[channel].proto);
  199.                 if (res2 == IR_OK && irRxChannel[channel].proto.protocol != IR_PROTO_UNKNOWN) {
  200.                     irTxMsg.Data[0] = 0xf&CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_PRESSED;
  201.                     irTxMsg.Data[0] |= channel<<4;
  202.                     irTxMsg.Data[1] = irRxChannel[channel].proto.protocol;
  203.                     irTxMsg.Data[2] = (irRxChannel[channel].proto.data>>24)&0xff;
  204.                     irTxMsg.Data[3] = (irRxChannel[channel].proto.data>>16)&0xff;
  205.                     irTxMsg.Data[4] = (irRxChannel[channel].proto.data>>8)&0xff;
  206.                     irTxMsg.Data[5] = irRxChannel[channel].proto.data&0xff;
  207.  
  208.                     StdCan_Put(&irTxMsg);
  209.                 }
  210.                 else if (irRxChannel[channel].proto.protocol == IR_PROTO_UNKNOWN)
  211.                 {
  212. #if (sns_irTransceive_SEND_DEBUG==1)
  213.                     send_debug(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen);
  214.                     irRxChannel[channel].proto.timeout=300;
  215. #endif
  216.                 }
  217.                
  218.                 /* Enable the receiver again */
  219.                 IrTransceiver_EnableRx(channel);
  220.                
  221.                 irRxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE;
  222.             }
  223.             break;
  224.  
  225.         case sns_irTransceive_STATE_START_PAUSE:
  226.             /* set a timer so we can send release button event when no new IR is arriving */
  227.             Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0);
  228.             irRxChannel[channel].state = sns_irTransceive_STATE_PAUSING;
  229.             break;
  230.  
  231.         case sns_irTransceive_STATE_PAUSING:
  232.             /* reset timer if new IR arrived */
  233.             if (irRxChannel[channel].newData == TRUE || IrTransceiver_GetStoreEnableRx(channel) == TRUE) {
  234.                 cli();
  235.                 irRxChannel[channel].newData = FALSE;
  236.                 sei();
  237.                 Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0);
  238.             }
  239.        
  240.             if (Timer_Expired(irRxChannel[channel].timerNum)) {
  241.                 irRxChannel[channel].state = sns_irTransceive_STATE_START_IDLE;
  242.             }
  243.             break;
  244.  
  245.         case sns_irTransceive_STATE_START_IDLE:
  246.             if (irRxChannel[channel].proto.protocol != IR_PROTO_UNKNOWN) {
  247.                 /* Send button release command on CAN */
  248.                 irTxMsg.Data[0] = 0xf&CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED;
  249.                 irTxMsg.Data[0] |= channel<<4;
  250.                 irTxMsg.Data[1] = irRxChannel[channel].proto.protocol;
  251.                 irTxMsg.Data[2] = (irRxChannel[channel].proto.data>>24)&0xff;
  252.                 irTxMsg.Data[3] = (irRxChannel[channel].proto.data>>16)&0xff;
  253.                 irTxMsg.Data[4] = (irRxChannel[channel].proto.data>>8)&0xff;
  254.                 irTxMsg.Data[5] = irRxChannel[channel].proto.data&0xff;
  255.  
  256.                 StdCan_Put(&irTxMsg);
  257.             }
  258.             irRxChannel[channel].state = sns_irTransceive_STATE_IDLE;
  259.             break;
  260.  
  261.         default:
  262.             break;
  263.         }
  264. #endif
  265.  
  266. #if IR_TX_ENABLE==1
  267.         switch (irTxChannel[channel].state)
  268.         {
  269.         case sns_irTransceive_STATE_IDLE:
  270.             /* transmission is started when a command is received on can */
  271.             break;
  272.  
  273.         case sns_irTransceive_STATE_START_TRANSMIT:
  274.             if (expandProtocol(irTxChannel[channel].txbuf, &irTxChannel[channel].txlen, &irTxChannel[channel].proto) == IR_OK)
  275.             {
  276.                 IrTransceiver_Transmit(channel, irTxChannel[channel].txbuf, irTxChannel[channel].txlen);
  277.                 irTxChannel[channel].state = sns_irTransceive_STATE_TRANSMITTING;
  278.             }
  279.             else
  280.             {
  281.                 irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
  282.             }
  283.             break;
  284.        
  285.         case sns_irTransceive_STATE_TRANSMITTING:
  286.             if (irTxChannel[channel].sendComplete == TRUE)
  287.             {
  288.                 cli();
  289.                 irTxChannel[channel].sendComplete = FALSE;
  290.                 sei();
  291.                 irTxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE;
  292.             }
  293.             break;
  294.  
  295.         case sns_irTransceive_STATE_START_PAUSE:
  296.             if (irTxChannel[channel].repeatCount < irTxChannel[channel].proto.repeats)
  297.             {
  298.                 irTxChannel[channel].repeatCount++;
  299.             }
  300.            
  301.             Timer_SetTimeout(irTxChannel[channel].timerNum, irTxChannel[channel].proto.timeout, TimerTypeOneShot, 0);
  302.  
  303.             if (irTxChannel[channel].proto.framecnt != 255)
  304.             {
  305.                 irTxChannel[channel].proto.framecnt++;
  306.             }
  307.            
  308.             irTxChannel[channel].state = sns_irTransceive_STATE_PAUSING;
  309.             break;
  310.  
  311.         case sns_irTransceive_STATE_PAUSING:
  312.             if (Timer_Expired(irTxChannel[channel].timerNum))
  313.             {
  314.                 irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT;
  315.             }
  316.            
  317.             /* transmission is stopped when such command is recevied on can */
  318.             if (irTxChannel[channel].stopSend == TRUE && irTxChannel[channel].repeatCount >= irTxChannel[channel].proto.repeats)
  319.             {
  320.                 //TODO maybe send message on can for status? to confirm stopped sending, ready for new command
  321.                 irTxChannel[channel].state = sns_irTransceive_STATE_START_IDLE;
  322.             }
  323.             break;
  324.  
  325.         case sns_irTransceive_STATE_START_IDLE:
  326.             irTxChannel[channel].stopSend = FALSE;
  327.             irTxChannel[channel].repeatCount = 0;
  328.             irTxChannel[channel].proto.framecnt = 0;
  329.            
  330.             irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
  331.             break;
  332.  
  333.         default:
  334.             break;
  335.         }
  336. #endif
  337.  
  338.     }
  339. }
  340.  
  341. /* Handle incoming CAN data */
  342. void sns_irTransceive_HandleMessage(StdCan_Msg_t *rxMsg)
  343. {
  344.     if (    StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_SNS &&
  345.         StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_TO_OWNER &&
  346.         rxMsg->Header.ModuleType == CAN_MODULE_TYPE_SNS_IRTRANSCEIVE &&
  347.         rxMsg->Header.ModuleId == sns_irTransceive_ID)
  348.     {
  349.         uint8_t channel;
  350.         switch (rxMsg->Header.Command)
  351.         {
  352.         case CAN_MODULE_CMD_PHYSICAL_IR:
  353.             channel = rxMsg->Data[0]>>4;
  354.             if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_PRESSED && channel < IR_SUPPORTED_NUM_CHANNELS)
  355.             {
  356.                 if (irTxChannel[channel].state == sns_irTransceive_STATE_IDLE)
  357.                 {
  358.                     irTxChannel[channel].proto.protocol = rxMsg->Data[1];
  359.  
  360.                     irTxChannel[channel].proto.data = rxMsg->Data[2];
  361.                     irTxChannel[channel].proto.data = irTxChannel[channel].proto.data<<8;
  362.                     irTxChannel[channel].proto.data |= rxMsg->Data[3];
  363.                     irTxChannel[channel].proto.data = irTxChannel[channel].proto.data<<8;
  364.                     irTxChannel[channel].proto.data |= rxMsg->Data[4];
  365.                     irTxChannel[channel].proto.data = irTxChannel[channel].proto.data<<8;
  366.                     irTxChannel[channel].proto.data |= rxMsg->Data[5];
  367.  
  368.                     irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT;
  369.                 }
  370.             }
  371.             else if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED && channel < IR_SUPPORTED_NUM_CHANNELS)
  372.             {
  373.                 if (irTxChannel[channel].state != sns_irTransceive_STATE_IDLE)
  374.                 {
  375.                     irTxChannel[channel].stopSend = TRUE;
  376.                 }
  377.             }
  378.             break;
  379.        
  380.         case CAN_MODULE_CMD_IRTRANSCEIVE_IRCONFIG:
  381.             channel = rxMsg->Data[0]>>4;
  382.             uint8_t config = rxMsg->Data[0] & 0x0f;
  383.             uint8_t power = rxMsg->Data[1]>>6;
  384.  
  385.             if (channel < IR_SUPPORTED_NUM_CHANNELS && config <= CAN_MODULE_ENUM_IRTRANSCEIVE_IRCONFIG_DIRECTION_RECEIVE && power < 4)
  386.             {
  387. #if IR_RX_ENABLE==1
  388.                 if (config == CAN_MODULE_ENUM_IRTRANSCEIVE_IRCONFIG_DIRECTION_RECEIVE)
  389.                 {
  390. #if IR_TX_ENABLE==1
  391.                     irTxChannel[channel].state = sns_irTransceive_STATE_DISABLED;
  392. #endif
  393.                     irRxChannel[channel].rxbuf = buf[channel];
  394.                     switch (channel)
  395.                     {
  396.                         case 0:
  397.                             gpio_clr_pin(sns_irTransceive_VCC_EN0_PIN);
  398.                             IrTransceiver_InitRxChannel(channel, irRxChannel[channel].rxbuf, sns_irTransceive_RX_done_callback, sns_irTransceive_RX0_PCINT, sns_irTransceive_RX0_PIN);
  399.                             break;
  400.                         case 1:
  401.                             gpio_clr_pin(sns_irTransceive_VCC_EN1_PIN);
  402.                             IrTransceiver_InitRxChannel(channel, irRxChannel[channel].rxbuf, sns_irTransceive_RX_done_callback, sns_irTransceive_RX1_PCINT, sns_irTransceive_RX1_PIN);
  403.                             break;
  404.                         case 2:
  405.                             gpio_clr_pin(sns_irTransceive_VCC_EN2_PIN);
  406.                             IrTransceiver_InitRxChannel(channel, irRxChannel[channel].rxbuf, sns_irTransceive_RX_done_callback, sns_irTransceive_RX2_PCINT, sns_irTransceive_RX2_PIN);
  407.                             break;
  408.                     }
  409.                     irRxChannel[channel].state = sns_irTransceive_STATE_RECEIVING;
  410.                 }
  411. #endif
  412.  
  413. #if IR_TX_ENABLE==1
  414.                 if (config == CAN_MODULE_ENUM_IRTRANSCEIVE_IRCONFIG_DIRECTION_TRANSMIT)
  415.                 {
  416. #if IR_RX_ENABLE==1
  417.                     irRxChannel[channel].state = sns_irTransceive_STATE_DISABLED;
  418. #endif
  419.                     irTxChannel[channel].txbuf = buf[channel];
  420.                     switch (channel)
  421.                     {
  422.                         case 0:
  423. #if IR_RX_ENABLE==1
  424.                             gpio_set_pin(sns_irTransceive_VCC_EN0_PIN);
  425.                             IrTransceiver_DeInitRxChannel(channel, sns_irTransceive_RX0_PCINT, sns_irTransceive_RX0_PIN);
  426. #endif
  427.                             IrTransceiver_InitTxChannel(channel, sns_irTransceive_TX_done_callback, sns_irTransceive_TX0_PIN);
  428.                             break;
  429.                         case 1:
  430. #if IR_RX_ENABLE==1
  431.                             gpio_set_pin(sns_irTransceive_VCC_EN1_PIN);
  432.                             IrTransceiver_DeInitRxChannel(channel, sns_irTransceive_RX1_PCINT, sns_irTransceive_RX1_PIN);
  433. #endif
  434.                             IrTransceiver_InitTxChannel(channel, sns_irTransceive_TX_done_callback, sns_irTransceive_TX1_PIN);
  435.                             break;
  436.                         case 2:
  437. #if IR_RX_ENABLE==1
  438.                             gpio_set_pin(sns_irTransceive_VCC_EN2_PIN);
  439.                             IrTransceiver_DeInitRxChannel(channel, sns_irTransceive_RX2_PCINT, sns_irTransceive_RX2_PIN);
  440. #endif
  441.                             IrTransceiver_InitTxChannel(channel, sns_irTransceive_TX_done_callback, sns_irTransceive_TX2_PIN);
  442.                             break;
  443.                     }
  444.                     irTxChannel[channel].state = sns_irTransceive_STATE_START_IDLE;
  445.                 }
  446. #endif
  447.             }
  448.             break;
  449.         }
  450.     }
  451. }
  452.  
  453. void sns_irTransceive_List(uint8_t ModuleSequenceNumber)
  454. {
  455.     StdCan_Msg_t txMsg;
  456.    
  457.     StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS);
  458.     StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER);
  459.     txMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE;
  460.  
  461.     txMsg.Header.ModuleId = sns_irTransceive_ID;
  462.     txMsg.Header.Command = CAN_MODULE_CMD_GLOBAL_LIST;
  463.     txMsg.Length = 6;
  464.  
  465.     txMsg.Data[0] = NODE_HW_ID_BYTE0;
  466.     txMsg.Data[1] = NODE_HW_ID_BYTE1;
  467.     txMsg.Data[2] = NODE_HW_ID_BYTE2;
  468.     txMsg.Data[3] = NODE_HW_ID_BYTE3;
  469.    
  470.     txMsg.Data[4] = NUMBER_OF_MODULES;
  471.     txMsg.Data[5] = ModuleSequenceNumber;
  472.    
  473.     while (StdCan_Put(&txMsg) != StdCan_Ret_OK);
  474. }
  475.