![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
Diff: RTno/SendPacket.cpp
- Revision:
- 0:b14546a3cfab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTno/SendPacket.cpp Fri Jul 29 11:23:06 2011 +0000 @@ -0,0 +1,35 @@ +/******************************************* + * SendPacket.cpp + * @author Yuki Suga + * @copyright Yuki Suga (ysuga.net) Nov, 10th, 2010. + * @license LGPLv3 + *****************************************/ +/******************************************** +It changed a little for mbed. +The serial buffer is not used. +2011/7/27 @nucho +********************************************/ +#include "Packet.h" +//#include <HardwareSerial.h> +//#include <WConstants.h> +#include "Serial.h" + +int SendPacket(const char interface, const char data_length, const char* packet_data) { + unsigned char sum = 0; + + pc.putc(interface); + sum += interface; + + pc.putc(data_length); + sum += data_length; + for(int i = 0;i < data_length;i++) { + sum += packet_data[i]; + pc.putc(packet_data[i]); + } + // if(data_length != 0) { + //n Serial.write((const uint8_t*)packet_data, data_length); + // } + //sum = 32; + pc.putc(sum); + return PACKET_HEADER_SIZE + data_length + 1; +}