avr/usart-dbus-bridge.c
void sendpacket(
	uint8_t machineId, 
	uint8_t commandId,
	void const * data,
	uint16_t length)
{
	DBUS_Send(machineId);
	DBUS_Send(commandId);
	if(data != NULL) {
		DBUS_Send(length);
		DBUS_Send(length >> 8);
		uint8_t const * ptr = (uint8_t const *)data;
		uint16_t checksum = 0;
		for(uint16_t i = 0; i < length; i++) {
			DBUS_Send(ptr[i]);
			checksum += ptr[i];
		}
		DBUS_Send(checksum);
		DBUS_Send(checksum >> 8);
	
	} else {
		DBUS_Send(0x00);
		DBUS_Send(0x00);
	}
}
/**
 * @brief Sends a packet in DBus protocol format
 */
@brief Sends a packet in DBus protocol format
@brief Sends a packet in DBus protocol format
void sendpacket(
	uint8_t machineId, 
	uint8_t commandId,
	void const * data,
	uint16_t length)
{
	DBUS_Send(machineId);
	DBUS_Send(commandId);
	if(data != NULL) {
		DBUS_Send(length);
		DBUS_Send(length >> 8);
		uint8_t const * ptr = (uint8_t const *)data;
		uint16_t checksum = 0;
		for(uint16_t i = 0; i < length; i++) {
			DBUS_Send(ptr[i]);
			checksum += ptr[i];
		}
		DBUS_Send(checksum);
		DBUS_Send(checksum >> 8);
	} else {
		DBUS_Send(0x00);
		DBUS_Send(0x00);
	}
}
void sendpacket ( uint8_t machineId , uint8_t commandId , void const * data , uint16_t length ) { DBUS_Send ( machineId ) ; DBUS_Send ( commandId ) ; if ( data != NULL ) { DBUS_Send ( length ) ; DBUS_Send ( length >> 8 ) ; uint8_t const * ptr = ( uint8_t const * ) data ; uint16_t checksum = 0 ; for ( uint16_t i = 0 ; i < length ; i ++ ) { DBUS_Send ( ptr [ i ] ) ; checksum += ptr [ i ] ; } DBUS_Send ( checksum ) ; DBUS_Send ( checksum >> 8 ) ; } else { DBUS_Send ( 0x00 ) ; DBUS_Send ( 0x00 ) ; } }
@brief Sends a packet in DBus protocol format
@brief Sends a packet in DBus protocol format