From 38ae118526307908ab60ba00b5bc7b8d0260b057 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 6 Apr 2019 11:46:41 -0400 Subject: [PATCH] Arduino 4 register read and AX.25 hex packet export --- afsk/ax25.c | 8 +++++++- afsk/main.c | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/afsk/ax25.c b/afsk/ax25.c index 15b127c2..d04e71eb 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +#include #include "ax25.h" #include #include "ax5043.h" @@ -89,6 +89,12 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, memcpy(__tx_buffer, hax25->addr_field, hax25->addr_field_len); memcpy(__tx_buffer + hax25->addr_field_len, payload, len); + printf("\n"); + int jj; + for(jj = 0; jj < 256; jj++) { + printf("%x",__tx_buffer[jj]); + } + printf("\n"); return ax5043_tx_frame(hax, __tx_buffer, len + hax25->addr_field_len, hax25->preamble_len, hax25->postable_len, 1000); } diff --git a/afsk/main.c b/afsk/main.c index 41c65c62..3b89e116 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -129,21 +129,34 @@ int main(void) { { fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); } else { - arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4B); + arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4b); fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C); if (arduinoI2C > 0) { - // for (blink = 1; blink < 20 ;blink++) { +/* // for (blink = 1; blink < 20 ;blink++) { sleep(1); fprintf(stderr,"Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); sleep(1); - fprintf(stderr,"Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); - sleep(1); + // fprintf(stderr,"Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + // sleep(1); printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); sleep(1); printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2)); sleep(1); // } - } else { +*/ + int reg; + int value; + for (reg = 0; reg < 4; reg++) { + usleep(100000); // wait 100ms for Arduino + value = wiringPiI2CReadReg16(arduinoI2C, reg); + if (value < 0) { + fprintf(stderr,"Error reading from register %d on Arduino\n", reg); + } else { + fprintf(stderr,"Read from register %d on Arduino value of %d\n", reg, value); + } + } + + } else { fprintf(stderr,"Arduino payload not present\n"); } }