module HdlcTranslateC {
provides interface SerialFrameComm;
uses {
- interface SerialByteComm;
+ interface UartStream;
interface Leds;
}
}
//norace uint8_t debugCnt = 0;
norace HdlcState state = {0,0};
norace uint8_t txTemp;
-
+ norace uint8_t m_data;
// TODO: add reset for when SerialM goes no-sync.
async command void SerialFrameComm.resetReceive(){
async command void SerialFrameComm.resetSend(){
state.sendEscape = 0;
}
- async event void SerialByteComm.get(uint8_t data) {
+ async event void UartStream.receivedByte(uint8_t data) {
//debugCnt++;
// 7E 41 0E 05 04 03 02 01 00 01 8F 7E
/* if (debugCnt == 1 && data == 0x7E) call Leds.led0On(); */
async command error_t SerialFrameComm.putDelimiter() {
state.sendEscape = 0;
- return call SerialByteComm.put(HDLC_FLAG_BYTE);
+ m_data = HDLC_FLAG_BYTE;
+ return call UartStream.send(&m_data, 1);
}
async command error_t SerialFrameComm.putData(uint8_t data) {
if (data == HDLC_CTLESC_BYTE || data == HDLC_FLAG_BYTE) {
state.sendEscape = 1;
txTemp = data ^ 0x20;
- return call SerialByteComm.put(HDLC_CTLESC_BYTE);
+ m_data = HDLC_CTLESC_BYTE;
}
else {
- return call SerialByteComm.put(data);
+ m_data = data;
}
+ return call UartStream.send(&m_data, 1);
}
- async event void SerialByteComm.putDone() {
+ async event void UartStream.sendDone( uint8_t* buf, uint16_t len,
+ error_t error ) {
if (state.sendEscape) {
state.sendEscape = 0;
- call SerialByteComm.put(txTemp);
+ m_data = txTemp;
+ call UartStream.send(&m_data, 1);
}
else {
signal SerialFrameComm.putDone();
}
}
+
+ async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t error ) {}
}