From bb5ec8bd106701d79ae84ef461f614f40cfc5ca4 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 19 Oct 2016 10:41:12 +0100 Subject: [PATCH] firmata: Remove all 6.2.x warnings Signed-off-by: Brendan Le Foll --- src/firmata/firmata.c | 23 +++++++++++------------ src/firmata/firmata_mraa.c | 14 ++++++++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/firmata/firmata.c b/src/firmata/firmata.c index 7da490f..67355b5 100644 --- a/src/firmata/firmata.c +++ b/src/firmata/firmata.c @@ -33,7 +33,6 @@ t_firmata* firmata_new(const char* name) { t_firmata* res; - mraa_result_t uart_res = MRAA_ERROR_UNSPECIFIED; res = calloc(1, sizeof(t_firmata)); if (!res) { @@ -69,7 +68,7 @@ firmata_close(t_firmata* firmata) int firmata_pull(t_firmata* firmata) { - uint8_t buff[FIRMATA_MSG_LEN]; + char buff[FIRMATA_MSG_LEN]; int r; r = mraa_uart_data_available(firmata->uart, 40); @@ -79,7 +78,7 @@ firmata_pull(t_firmata* firmata) return 0; } if (r > 0) { - firmata_parse(firmata, buff, r); + firmata_parse(firmata, (uint8_t*) buff, r); return r; } } @@ -174,7 +173,7 @@ firmata_endParse(t_firmata* firmata) // not ready to communicate for some time, so the only // way to reliably query their capabilities is to wait // until the REPORT_FIRMWARE message is heard. - uint8_t buf[80]; + char buf[80]; len = 0; buf[len++] = FIRMATA_START_SYSEX; buf[len++] = FIRMATA_ANALOG_MAPPING_QUERY; // read analog to pin # info @@ -209,7 +208,7 @@ firmata_endParse(t_firmata* firmata) } // send a state query for for every pin with any modes for (pin = 0; pin < 128; pin++) { - uint8_t buf[512]; + char buf[512]; int len = 0; if (firmata->pins[pin].supported_modes) { buf[len++] = FIRMATA_START_SYSEX; @@ -241,7 +240,7 @@ firmata_endParse(t_firmata* firmata) int reg = (firmata->parse_buff[4] & 0x7f) | ((firmata->parse_buff[5] & 0x7f) << 7); int i = 6; int ii = 0; - for (ii; ii < (firmata->parse_count - 7) / 2; ii++) { + for (; ii < (firmata->parse_count - 7) / 2; ii++) { firmata->i2cmsg[addr][reg+ii] = (firmata->parse_buff[i] & 0x7f) | ((firmata->parse_buff[i+1] & 0x7f) << 7); i = i+2; } @@ -249,7 +248,7 @@ firmata_endParse(t_firmata* firmata) if (firmata->devs != NULL) { struct _firmata* devs = firmata->devs[0]; int i = 0; - for (i; i < firmata->dev_count; i++, devs++) { + for (; i < firmata->dev_count; i++, devs++) { if (devs != NULL) { if (firmata->parse_buff[1] == devs->feature) { // call func @@ -284,7 +283,7 @@ firmata_initPins(t_firmata* firmata) int firmata_askFirmware(t_firmata* firmata) { - uint8_t buf[3]; + char buf[3]; int res; buf[0] = FIRMATA_START_SYSEX; @@ -298,7 +297,7 @@ int firmata_pinMode(t_firmata* firmata, int pin, int mode) { int res; - uint8_t buff[4]; + char buff[4]; firmata->pins[pin].mode = mode; buff[0] = FIRMATA_SET_PIN_MODE; @@ -313,7 +312,7 @@ firmata_analogWrite(t_firmata* firmata, int pin, int value) { int res; - uint8_t buff[3]; + char buff[3]; buff[0] = 0xE0 | pin; buff[1] = value & 0x7F; buff[2] = (value >> 7) & 0x7F; @@ -326,7 +325,7 @@ firmata_analogRead(t_firmata *firmata, int pin) { int res; int value = 1; - uint8_t buff[2]; + char buff[2]; buff[0] = FIRMATA_REPORT_ANALOG | pin; buff[1] = value; res = mraa_uart_write(firmata->uart, buff, 2); @@ -338,7 +337,7 @@ firmata_digitalWrite(t_firmata* firmata, int pin, int value) { int i; int res; - uint8_t buff[4]; + char buff[4]; if (pin < 0 || pin > 127) return (0); diff --git a/src/firmata/firmata_mraa.c b/src/firmata/firmata_mraa.c index 1100773..f515972 100644 --- a/src/firmata/firmata_mraa.c +++ b/src/firmata/firmata_mraa.c @@ -92,7 +92,7 @@ static mraa_result_t mraa_firmata_i2c_init_bus_replace(mraa_i2c_context dev) { int delay = 1; // this should be either 1 or 0, I don't know :) - uint8_t buff[4]; + char buff[4]; buff[0] = FIRMATA_START_SYSEX; buff[1] = FIRMATA_I2C_CONFIG; buff[2] = delay & 0xFF, (delay >> 8) & 0xFF; @@ -120,7 +120,7 @@ mraa_firmata_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode) static mraa_result_t mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length) { - uint8_t* buffer = calloc(7, 0); + char* buffer = calloc(7, 0); if (buffer == NULL) { return MRAA_ERROR_NO_RESOURCES; } @@ -149,7 +149,7 @@ mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length) static mraa_result_t mraa_firmata_send_i2c_read_reg_req(mraa_i2c_context dev, uint8_t command, int length) { - uint8_t* buffer = calloc(9, 0); + char* buffer = calloc(9, 0); if (buffer == NULL) { return MRAA_ERROR_NO_RESOURCES; } @@ -266,7 +266,7 @@ mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWri { // buffer needs 5 bytes for firmata, and 2 bytes for every byte of data int buffer_size = (bytesToWrite*2) + 5; - uint8_t* buffer = calloc(buffer_size, 0); + char* buffer = calloc(buffer_size, 0); if (buffer == NULL) { return MRAA_ERROR_NO_RESOURCES; } @@ -291,7 +291,7 @@ mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWri static mraa_result_t mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data) { - uint8_t* buffer = calloc(7, 0); + char* buffer = calloc(7, 0); if (buffer == NULL) { return MRAA_ERROR_NO_RESOURCES; } @@ -310,7 +310,7 @@ mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data) static mraa_result_t mraa_firmata_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command) { - uint8_t* buffer = calloc(9, 0); + char* buffer = calloc(9, 0); if (buffer == NULL) { return MRAA_ERROR_NO_RESOURCES; } @@ -517,6 +517,8 @@ mraa_firmata_pull_handler(void* vp) isr_prev = isr_now; usleep(100); } + + return NULL; } mraa_board_t*