From c504853e0cb20a65cc92fca661d745e084c989c9 Mon Sep 17 00:00:00 2001 From: "Ake Hedman, Paradise of the Frog" Date: Tue, 8 Dec 2015 14:02:29 +0100 Subject: [PATCH] Added unsigned integer/long construct macros also because I "luve" symmetry. --- common/vscp_firmware.c | 8 +++++--- common/vscp_firmware.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/common/vscp_firmware.c b/common/vscp_firmware.c index 5ce7cbb4..60f2e4ae 100644 --- a/common/vscp_firmware.c +++ b/common/vscp_firmware.c @@ -686,8 +686,8 @@ uint8_t vscp_readStdReg(uint8_t reg) else if ( reg >= VSCP_REG_DEVICE_URL ) { // * * * The device URL * * * - rv = vscp_getMDF_URL(reg - VSCP_REG_DEVICE_URL); - + rv = vscp_getMDF_URL(reg - VSCP_REG_DEVICE_URL); + } return rv; @@ -1152,6 +1152,7 @@ void vscp_handleProtocolEvent(void) #endif case VSCP_TYPE_PROTOCOL_EXTENDED_PAGE_READ: + if ( vscp_nickname == vscp_imsg.data[0] ) { uint16_t page_save, bytes = 0; @@ -1211,7 +1212,7 @@ void vscp_handleProtocolEvent(void) // send the event vscp_sendEvent(); - + // increment byte by bytes_this_time and the event number by one byte += bytes_this_time; @@ -1286,6 +1287,7 @@ void vscp_handleProtocolEvent(void) int8_t vscp_sendEvent(void) { int8_t rv; + if ( !(rv = sendVSCPFrame( vscp_omsg.vscp_class, vscp_omsg.vscp_type, vscp_nickname, diff --git a/common/vscp_firmware.h b/common/vscp_firmware.h index 62d559f5..6d6b2991 100644 --- a/common/vscp_firmware.h +++ b/common/vscp_firmware.h @@ -71,12 +71,23 @@ low end hardware device. #define construct_signed16( msb, lsb ) ((int16_t)( (((uint16_t)msb)<<8) + \ (uint16_t)lsb) ) +// This macro construct a unsigned integer from two unsigned chars in a safe way +#define construct_unsigned16( msb, lsb ) ((uint16_t)( (((uint16_t)msb)<<8) + \ + (uint16_t)lsb) ) + // This macro construct a signed long from four unsigned chars in a safe way #define construct_signed32( b0, b1, b2, b3 ) ((int32_t)( (((uint32_t)b0)<<24) + \ (((uint32_t)b0)<<16) + \ (((uint32_t)b0)<<8) + \ ((uint32_t)b0); +// This macro construct a unsigned long from four unsigned chars in a safe way +#define construct_unsigned32( b0, b1, b2, b3 ) ((uint32_t)( (((uint32_t)b0)<<24) + \ + (((uint32_t)b0)<<16) + \ + (((uint32_t)b0)<<8) + \ + ((uint32_t)b0); + + // ****************************************************************************** // VSCP Constants // ******************************************************************************