summaryrefslogtreecommitdiff
path: root/serial-pjon
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-10-20 02:23:32 +0200
committerChristian Pointner <equinox@spreadspace.org>2016-10-20 02:23:32 +0200
commitf34f40971b9cfea80e28ccf3c5e02f1991f87784 (patch)
treea4a12049aef7d0337b305e6689e200ac78c5b28f /serial-pjon
parentwhitespace cleanup (diff)
importing pjon-5.2 (still compile errors=pjon5
Diffstat (limited to 'serial-pjon')
-rw-r--r--serial-pjon/Makefile2
-rw-r--r--serial-pjon/serial-pjon.cpp31
2 files changed, 18 insertions, 15 deletions
diff --git a/serial-pjon/Makefile b/serial-pjon/Makefile
index be3dd35..3cc35b1 100644
--- a/serial-pjon/Makefile
+++ b/serial-pjon/Makefile
@@ -28,7 +28,7 @@ CXX_LIBS := arduino-stub
EXTERNAL_LIBS := pjon
SPREADAVR_PATH := ..
-PJON_PATH := $(SPREADAVR_PATH)/contrib/PJON-3.0
+PJON_PATH := $(SPREADAVR_PATH)/../pjon/
PJON_OPTS :=
include $(SPREADAVR_PATH)/include.mk
diff --git a/serial-pjon/serial-pjon.cpp b/serial-pjon/serial-pjon.cpp
index 7c3a116..bb1320d 100644
--- a/serial-pjon/serial-pjon.cpp
+++ b/serial-pjon/serial-pjon.cpp
@@ -44,28 +44,31 @@ void error_handler(uint8_t code, uint8_t data) {
printf("Possible wrong bus configuration!\r\n");
printf("higher MAX_PACKETS in PJON.h if necessary.\r\n");
}
- if(code == MEMORY_FULL) {
- printf("Packet memory allocation failed. Memory is full.\r\n");
- }
if(code == CONTENT_TOO_LONG) {
printf("Content is too long, length: %d\r\n", data);
}
if(code == ID_ACQUISITION_FAIL) {
printf("Can't acquire a free id %d\r\n", data);
}
+ if(code == DEVICES_BUFFER_FULL) {
+ printf("Packet memory allocation failed. Memory is full.\r\n");
+ }
}
-void recv_handler(uint8_t id, uint8_t *payload, uint8_t length) {
- if(length == 0) {
- printf("got 0 byte message from %d...\r\n", id);
- return;
- }
+void recv_handler(uint8_t *payload, uint8_t length, const PacketInfo &packet_info) {
+
+
+
+ // if(length == 0) {
+ // printf("got 0 byte message from %d.%d.%d.%d...\r\n");
+ // return;
+ // }
led_on();
- printf("got message(%d bytes) from %d: '", length, id);
- for(uint16_t i = 0; i < length; ++i)
- putchar(payload[i]);
- printf("'\r\n");
- delay(30);
+ // printf("got message(%d bytes) from %d: '", length, id);
+ // for(uint16_t i = 0; i < length; ++i)
+ // putchar(payload[i]);
+ // printf("'\r\n");
+ // delay(30);
led_off();
}
@@ -97,7 +100,7 @@ int main(void)
arduino_init();
bus.set_error(error_handler);
bus.set_receiver(recv_handler);
- bus.set_pin(8);
+ bus.strategy.set_pins(8, NOT_ASSIGNED);
bus.begin();
for(;;) {