summaryrefslogtreecommitdiffstats
path: root/serial_link/protocol
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-02-20 15:14:40 +0200
committerFred Sundvik <fsundvik@gmail.com>2016-02-20 15:14:40 +0200
commit532f98eef6a29ae83d7ed61fbc4e25e23ad972d5 (patch)
tree55022ea7f326feac65c3ea1ea77b0af9f91cf1ae /serial_link/protocol
parentc28e19c5467e92f532f64db020ad4817b531dbec (diff)
Support for other links sending to master
Diffstat (limited to 'serial_link/protocol')
-rw-r--r--serial_link/protocol/frame_router.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/serial_link/protocol/frame_router.c b/serial_link/protocol/frame_router.c
index 480673f0c0..c61c50ebd6 100644
--- a/serial_link/protocol/frame_router.c
+++ b/serial_link/protocol/frame_router.c
@@ -33,20 +33,27 @@ void router_set_master(bool master) {
void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){
if (is_master) {
- transport_recv_frame(1, data, size);
+ transport_recv_frame(data[size-1], data, size - 1);
}
else {
- if (data[size-1] & 1) {
- transport_recv_frame(0, data, size - 1);
+ if (link == UP_LINK) {
+ if (data[size-1] & 1) {
+ transport_recv_frame(0, data, size - 1);
+ }
+ data[size-1] >>= 1;
+ validator_send_frame(DOWN_LINK, data, size);
+ }
+ else {
+ data[size-1]++;
+ validator_send_frame(UP_LINK, data, size);
}
- data[size-1] >>= 1;
- validator_send_frame(DOWN_LINK, data, size);
}
}
void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
if (destination == 0) {
- validator_send_frame(UP_LINK, data, size);
+ data[size] = 1;
+ validator_send_frame(UP_LINK, data, size + 1);
}
else {
data[size] = destination;