mfrc_reader/libraries/BufferedSerial/BufferedSerial.cpp
// Sends a packet with a header and a checksum
Sends a packet with a header and a checksum
Sends a packet with a header and a checksum
int BufferedSerial::sendSerialPacket(ByteBuffer* packet_buffer){
	byte checksum = 0;
	while( packet_buffer->getSize() > 0 ){
		byte b = packet_buffer->get();
		outgoing_buffer->put(b);
		checksum += b;
	}
	outgoing_buffer->put( checksum );
	outgoing_buffer->put( 1 );
	outgoing_buffer->put( 2 );
	outgoing_buffer->put( 3 );
	outgoing_buffer->put( 4 );
	return 0;
}
int BufferedSerial :: sendSerialPacket ( ByteBuffer * packet_buffer ) { byte checksum = 0 ; while ( packet_buffer -> getSize ( ) > 0 ) { byte b = packet_buffer -> get ( ) ; outgoing_buffer -> put ( b ) ; checksum += b ; } outgoing_buffer -> put ( checksum ) ; outgoing_buffer -> put ( 1 ) ; outgoing_buffer -> put ( 2 ) ; outgoing_buffer -> put ( 3 ) ; outgoing_buffer -> put ( 4 ) ; return 0 ; }
Sends a packet with a header and a checksum
Sends a packet with a header and a checksum
// Copy buffer and calc checksum