/////////////////////////////////////////////////////////////////////////////// // vscp_rcv_readreg // void vscp_readStdReg( void ) { SendMsg.priority = VSCP_PRIORITY_HIGH; SendMsg.length = 2; SendMsg.vscp_class = VSCP_CLASS1_PROTOCOL; SendMsg.vscp_type = VSCP_TYPE_PROTOCOL_RW_RESPONSE; SendMsg.data[0] = RxMsg.data[1]; SendMsg.data[1] = 0; // Default if ( VSCP_REG_ALARMSTATUS == RxMsg.data[1]) { // * * * Read alarm status register * * * SendMsg.data[1] = vscp_alarmstatus; vscp_alarmstatus = 0x00; // Reset alarm status } else if ( VSCP_REG_VSCP_MAJOR_VERSION == RxMsg.data[1]) { // * * * VSCP Protocol Major Version * * * SendMsg.data[1] = VSCP_MAJOR_VERSION; } else if ( VSCP_REG_VSCP_MINOR_VERSION == RxMsg.data[1]) { // * * * VSCP Protocol Minor Version * * * SendMsg.data[1] = VSCP_MINOR_VERSION; } else if ( VSCP_REG_NODE_CONTROL == RxMsg.data[1]) { // * * * Reserved * * * SendMsg.data[1] = 0; } else if ( VSCP_FIRMWARE_MAJOR_VERSION == RxMsg.data[1]) { // * * * Get firmware Major version * * * SendMsg.data[1] = vscp_getMajorVersion(); } else if ( VSCP_FIRMWARE_MINOR_VERSION == RxMsg.data[1]) { // * * * Get firmware Minor version * * * SendMsg.data[1] = vscp_getMinorVersion(); } else if ( VSCP_FIRMWARE_SUB_MINOR_VERSION == RxMsg.data[1]) { // * * * Get firmware Sub Minor version * * * SendMsg.data[1] = vscp_getSubMinorVersion(); } else if ( RxMsg.data[1] < VSCP_REG_MANUFACTUR_ID0) { // * * * Read from persitant locations * * * SendMsg.data[1] = vscp_getUserID( RxMsg.data[1] - VSCP_REG_USERID0); } else if (( RxMsg.data[1] > VSCP_REG_USERID4)&& ( RxMsg.data[1] < VSCP_REG_NICKNAME_ID)) { // * * * Manufacturer ID information * * * SendMsg.data[1] = vscp_getManufacturerId( RxMsg.data[1] - VSCP_REG_MANUFACTUR_ID0); } else if ( VSCP_REG_NICKNAME_ID == RxMsg.data[1]) { // * * * nickname id * * * SendMsg.data[1] = vscp_nickname; } else if ( VSCP_REG_PAGE_SELECT_LSB == RxMsg.data[1]) { // * * * Page select LSB * * * SendMsg.data[1] = ( vscp_page_select & 0xff ); } else if ( VSCP_REG_PAGE_SELECT_MSB == RxMsg.data[1]) { // * * * Page select MSB * * * SendMsg.data[1] = ( vscp_page_select >> 8 ) & 0xff; }
uint8_t vscp_readStdReg(uint8_t reg) { uint8_t rv = 0; if (VSCP_REG_ALARMSTATUS == reg) { // * * * Read alarm status register * * * rv = vscp_alarmstatus; vscp_alarmstatus = 0x00; // Reset alarm status } else if (VSCP_REG_VSCP_MAJOR_VERSION == reg) { // * * * VSCP Protocol Major Version * * * rv = VSCP_MAJOR_VERSION; } else if (VSCP_REG_VSCP_MINOR_VERSION == reg) { // * * * VSCP Protocol Minor Version * * * rv = VSCP_MINOR_VERSION; } else if (VSCP_REG_NODE_CONTROL == reg) { // * * * Reserved * * * rv = 0; } else if (VSCP_REG_FIRMWARE_MAJOR_VERSION == reg) { // * * * Get firmware Major version * * * rv = vscp_getMajorVersion(); } else if (VSCP_REG_FIRMWARE_MINOR_VERSION == reg) { // * * * Get firmware Minor version * * * rv = vscp_getMinorVersion(); } else if (VSCP_REG_FIRMWARE_SUB_MINOR_VERSION == reg) { // * * * Get firmware Sub Minor version * * * rv = vscp_getSubMinorVersion(); } else if (reg < VSCP_REG_MANUFACTUR_ID0) { // * * * Read from persitant locations * * * rv = vscp_getUserID(reg - VSCP_REG_USERID0); } else if ((reg > VSCP_REG_USERID4) && (reg < VSCP_REG_NICKNAME_ID)) { // * * * Manufacturer ID information * * * rv = vscp_getManufacturerId(reg - VSCP_REG_MANUFACTUR_ID0); } else if (VSCP_REG_NICKNAME_ID == reg) { // * * * nickname id * * * rv = vscp_nickname; } else if (VSCP_REG_PAGE_SELECT_LSB == reg) { // * * * Page select LSB * * * rv = (vscp_page_select & 0xff); } else if (VSCP_REG_PAGE_SELECT_MSB == reg) { // * * * Page select MSB * * * rv = (vscp_page_select >> 8) & 0xff; }