Arduino 4 register read and AX.25 hex packet export

pull/22/head
Alan Johnston 7 years ago
parent 4c54f88c32
commit 38ae118526

@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h>
#include "ax25.h" #include "ax25.h"
#include <string.h> #include <string.h>
#include "ax5043.h" #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, hax25->addr_field_len);
memcpy(__tx_buffer + hax25->addr_field_len, payload, 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, return ax5043_tx_frame(hax, __tx_buffer, len + hax25->addr_field_len,
hax25->preamble_len, hax25->postable_len, 1000); hax25->preamble_len, hax25->postable_len, 1000);
} }

@ -129,21 +129,34 @@ int main(void) {
{ {
fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n");
} else { } else {
arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4B); arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4b);
fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C); fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C);
if (arduinoI2C > 0) { if (arduinoI2C > 0) {
// for (blink = 1; blink < 20 ;blink++) { /* // for (blink = 1; blink < 20 ;blink++) {
sleep(1); sleep(1);
fprintf(stderr,"Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); fprintf(stderr,"Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0));
sleep(1); sleep(1);
fprintf(stderr,"Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); // fprintf(stderr,"Arduio: %d \n", wiringPiI2CRead(arduinoI2C));
sleep(1); // sleep(1);
printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1));
sleep(1); sleep(1);
printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2)); printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2));
sleep(1); 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"); fprintf(stderr,"Arduino payload not present\n");
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.