diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2016-02-20 15:02:53 +0200 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2016-02-20 15:02:53 +0200 |
commit | c28e19c5467e92f532f64db020ad4817b531dbec (patch) | |
tree | 422fab5c4a8bbc6e623c14e0366065c9e2d3cd2f /serial_link/protocol | |
parent | 82b5037b9db628c3f34d8fb38848753ff3e41e2f (diff) |
First link sending to master
Diffstat (limited to 'serial_link/protocol')
-rw-r--r-- | serial_link/protocol/frame_router.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/serial_link/protocol/frame_router.c b/serial_link/protocol/frame_router.c index 861c0d7d29..480673f0c0 100644 --- a/serial_link/protocol/frame_router.c +++ b/serial_link/protocol/frame_router.c @@ -32,14 +32,24 @@ void router_set_master(bool master) { } void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){ - if (data[size-1] & 1) { - transport_recv_frame(0, data, size - 1); + if (is_master) { + transport_recv_frame(1, data, size); + } + else { + if (data[size-1] & 1) { + transport_recv_frame(0, data, size - 1); + } + data[size-1] >>= 1; + validator_send_frame(DOWN_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) { - data[size] = destination; - validator_send_frame(DOWN_LINK, data, size + 1); + if (destination == 0) { + validator_send_frame(UP_LINK, data, size); + } + else { + data[size] = destination; + validator_send_frame(DOWN_LINK, data, size + 1); + } } |