aboutsummaryrefslogtreecommitdiff
path: root/arduino/ace_cpp_old/Framer.cpp
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2013-02-26 16:38:19 +0100
committerJakob Odersky <jodersky@gmail.com>2013-02-26 16:38:19 +0100
commit5d4fd43bbccd3b1da97d3139b95eab9173777bef (patch)
treee0c4afeda484259bf725f25c3d891e30853ee8dd /arduino/ace_cpp_old/Framer.cpp
parentac31762b462f37d49999daae8dba7763d8d870b3 (diff)
downloadace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.tar.gz
ace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.tar.bz2
ace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.zip
remove old c/c++ implementations
Diffstat (limited to 'arduino/ace_cpp_old/Framer.cpp')
-rw-r--r--arduino/ace_cpp_old/Framer.cpp101
1 files changed, 0 insertions, 101 deletions
diff --git a/arduino/ace_cpp_old/Framer.cpp b/arduino/ace_cpp_old/Framer.cpp
deleted file mode 100644
index 03335af..0000000
--- a/arduino/ace_cpp_old/Framer.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "Framer.h"
-
-Framer::Framer():
- state(WAITING),
- position(-1),
- checksum(0) {
-}
-
-void Framer::reset() {
- position = -1;
- checksum = 0x00;
-}
-
-void Framer::accept(uint8_t byte) {
-
- //if a new byte would cause an overflow, restart frame
- //note that this should not happen if both communicating parties have defined the same maximum frame length
- if (position >= MAX_FRAME_SIZE) {
- reset();
- return;
- }
-
- if (position != -1) { // i.e. a previous byte exists
- frameBuffer[position] = staged;
- checksum = checksum ^ staged;
- }
-
- position += 1;
- staged = byte;
-
-}
-
-void Framer::put(uint8_t byte) {
-
- switch(state) {
- case ESCAPING:
- accept(byte);
- state = RECEIVING;
- break;
-
- case WAITING:
- if (byte == START) {
- reset();
- state = RECEIVING;
- }
- break;
-
- case RECEIVING:
- switch(byte) {
- case ESCAPE:
- state = ESCAPING;
- break;
- case START:
- reset();
- break;
- case STOP:
- state = WAITING;
- if (staged == checksum) { //at this point, staged byte is the checksum sent in the frame (last byte of frame)
- onFrame(position, frameBuffer);
- }
- break;
-
- default:
- accept(byte);
- break;
- }
- }
-}
-
-
-
-void Framer::send(uint16_t length, const uint8_t * const data) {
- uint8_t checksum = 0x00;
- uint8_t byte;
-
- onSendByte(START);
- for (int i = 0; i < length; ++i) {
- byte = data[i];
- if (isCommandByte(byte))
- onSendByte(ESCAPE);
- checksum = checksum ^ byte;
- isCommandByte(byte);
- }
- if (isCommandByte(checksum)) {
- onSendByte(ESCAPE);
- }
- onSendByte(checksum);
- onSendByte(STOP);
-};
-
-
- //~ cli();
- //~ TCCR1A = 0; // set entire TCCR1A register to 0
- //~ TCCR1B = 0; // same for TCCR1B
- //~ // turn on CTC mode:
- //~ TCCR1B |= (1 << WGM12);
- //~ // set CS31 for 64 prescaler
- //~ TCCR1B |= (1 << CS11);
- //~ // set compare match register to desired timer count:
- //~ OCR1A = F_CPU / 1000 / 64; // should be 250 for F_CPU=16Mhz and f = 1000Hz
- //~ sei();