From 2c0ffe30b6503df08e6dd90a36f154a5ba5578c9 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 4 Dec 2016 20:51:19 +0100 Subject: [PATCH] Fixed debug output Added better test --- software/linux/libsss7.c | 2 +- software/linux/test.c | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/software/linux/libsss7.c b/software/linux/libsss7.c index 1586b43..ead0207 100644 --- a/software/linux/libsss7.c +++ b/software/linux/libsss7.c @@ -107,7 +107,7 @@ void *eventloop(void *arg) { // Or read a byte send by somebody else. res = read(serial_fd, &uart_rx_byte, 1); if(res == 1) { - printf("Read %x\n", uart_tx_byte); + printf("Read %x\n", uart_rx_byte); // Lock mutexes and call rx handler pthread_mutex_lock(&state_mutex); pthread_mutex_lock(&rx_buffer_mutex); diff --git a/software/linux/test.c b/software/linux/test.c index f75db5c..cf97351 100644 --- a/software/linux/test.c +++ b/software/linux/test.c @@ -11,28 +11,31 @@ int main(int argc, char const *argv[]) { uint8_t msg[LIBSSS7_PAYLOAD_SIZE]; memset(msg, 0, LIBSSS7_PAYLOAD_SIZE); msg[0] = 'H'; - msg[1] = 'e'; + msg[1] = 'a'; msg[2] = 'l'; msg[3] = 'l'; msg[4] = 'o'; msg[5] = ' '; msg[6] = 'W'; - msg[7] = 'o'; - msg[8] = 'r'; - msg[9] = 'l'; - msg[10] = 'd'; + msg[7] = 'e'; + msg[8] = 'l'; + msg[9] = 't'; - //while(1) { + while(!libsss7_can_send()); + libsss7_send(msg); + while(!libsss7_can_send()); + if(libsss7_send_failed()) { + printf("Send failed\n"); + } + + while(!libsss7_has_received()); + uint8_t tmp[LIBSSS7_PAYLOAD_SIZE + 1]; + memset(tmp, 0, LIBSSS7_PAYLOAD_SIZE + 1); + libsss7_get_received(tmp); + printf("Received: %s\n", tmp); + - while(!libsss7_can_send()); - libsss7_send(msg); - while(!libsss7_can_send()); - if(libsss7_send_failed()) { - printf("Send failed\n"); - } - sleep(5); - //} libsss7_send(msg);