Subversion Repositories HomeAutomation

Rev

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