grodansparadis / vscp-firmware

Firmware for the VSCP project
http://www.vscp.org
28 stars 9 forks source link

Possible bug in SendInformationEvent() #8

Open waaslandwolf opened 9 years ago

waaslandwolf commented 9 years ago

The current implementation of SendInformationEvent() in my Hasselt/Paris-based firmware is:

void SendInformationEvent( unsigned char idx, unsigned char eventClass, unsigned char eventTypeId) 

{
    vscp_omsg.priority = VSCP_PRIORITY_MEDIUM;
    vscp_omsg.flags = VSCP_VALID_MSG + 3;
    vscp_omsg.vscp_class = eventClass;
    vscp_omsg.vscp_type = eventTypeId;

    vscp_omsg.data[ 0 ] = idx;                                          //index
    vscp_omsg.data[ 1 ] = readEEPROM( VSCP_EEPROM_END + EEPROM_ZONE );  //zone
    vscp_omsg.data[ 2 ] = readEEPROM( VSCP_EEPROM_END + idx );          //subzone

    vscp_sendEvent();   // Send data
}

omsg.data[2] should be the subzone as per the protocol specification. In the case of my MDF the subzone register is indeed located at _VSCP_EEPROMEND + idx, but in case the register order in the MDF changes this will no longer be the case.

Wouldn't it be better to use this instead? vscp_omsg.data[ 2 ] = readEEPROM( VSCP_EEPROM_END + EEPROM_SUBZONE );