Private
Public Access
2
0

firmata: Remove all 6.2.x warnings

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-10-19 10:41:12 +01:00
parent a3c717553c
commit bb5ec8bd10
2 changed files with 19 additions and 18 deletions

View File

@@ -33,7 +33,6 @@ t_firmata*
firmata_new(const char* name) firmata_new(const char* name)
{ {
t_firmata* res; t_firmata* res;
mraa_result_t uart_res = MRAA_ERROR_UNSPECIFIED;
res = calloc(1, sizeof(t_firmata)); res = calloc(1, sizeof(t_firmata));
if (!res) { if (!res) {
@@ -69,7 +68,7 @@ firmata_close(t_firmata* firmata)
int int
firmata_pull(t_firmata* firmata) firmata_pull(t_firmata* firmata)
{ {
uint8_t buff[FIRMATA_MSG_LEN]; char buff[FIRMATA_MSG_LEN];
int r; int r;
r = mraa_uart_data_available(firmata->uart, 40); r = mraa_uart_data_available(firmata->uart, 40);
@@ -79,7 +78,7 @@ firmata_pull(t_firmata* firmata)
return 0; return 0;
} }
if (r > 0) { if (r > 0) {
firmata_parse(firmata, buff, r); firmata_parse(firmata, (uint8_t*) buff, r);
return r; return r;
} }
} }
@@ -174,7 +173,7 @@ firmata_endParse(t_firmata* firmata)
// not ready to communicate for some time, so the only // not ready to communicate for some time, so the only
// way to reliably query their capabilities is to wait // way to reliably query their capabilities is to wait
// until the REPORT_FIRMWARE message is heard. // until the REPORT_FIRMWARE message is heard.
uint8_t buf[80]; char buf[80];
len = 0; len = 0;
buf[len++] = FIRMATA_START_SYSEX; buf[len++] = FIRMATA_START_SYSEX;
buf[len++] = FIRMATA_ANALOG_MAPPING_QUERY; // read analog to pin # info 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 // send a state query for for every pin with any modes
for (pin = 0; pin < 128; pin++) { for (pin = 0; pin < 128; pin++) {
uint8_t buf[512]; char buf[512];
int len = 0; int len = 0;
if (firmata->pins[pin].supported_modes) { if (firmata->pins[pin].supported_modes) {
buf[len++] = FIRMATA_START_SYSEX; 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 reg = (firmata->parse_buff[4] & 0x7f) | ((firmata->parse_buff[5] & 0x7f) << 7);
int i = 6; int i = 6;
int ii = 0; 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); firmata->i2cmsg[addr][reg+ii] = (firmata->parse_buff[i] & 0x7f) | ((firmata->parse_buff[i+1] & 0x7f) << 7);
i = i+2; i = i+2;
} }
@@ -249,7 +248,7 @@ firmata_endParse(t_firmata* firmata)
if (firmata->devs != NULL) { if (firmata->devs != NULL) {
struct _firmata* devs = firmata->devs[0]; struct _firmata* devs = firmata->devs[0];
int i = 0; int i = 0;
for (i; i < firmata->dev_count; i++, devs++) { for (; i < firmata->dev_count; i++, devs++) {
if (devs != NULL) { if (devs != NULL) {
if (firmata->parse_buff[1] == devs->feature) { if (firmata->parse_buff[1] == devs->feature) {
// call func // call func
@@ -284,7 +283,7 @@ firmata_initPins(t_firmata* firmata)
int int
firmata_askFirmware(t_firmata* firmata) firmata_askFirmware(t_firmata* firmata)
{ {
uint8_t buf[3]; char buf[3];
int res; int res;
buf[0] = FIRMATA_START_SYSEX; buf[0] = FIRMATA_START_SYSEX;
@@ -298,7 +297,7 @@ int
firmata_pinMode(t_firmata* firmata, int pin, int mode) firmata_pinMode(t_firmata* firmata, int pin, int mode)
{ {
int res; int res;
uint8_t buff[4]; char buff[4];
firmata->pins[pin].mode = mode; firmata->pins[pin].mode = mode;
buff[0] = FIRMATA_SET_PIN_MODE; buff[0] = FIRMATA_SET_PIN_MODE;
@@ -313,7 +312,7 @@ firmata_analogWrite(t_firmata* firmata, int pin, int value)
{ {
int res; int res;
uint8_t buff[3]; char buff[3];
buff[0] = 0xE0 | pin; buff[0] = 0xE0 | pin;
buff[1] = value & 0x7F; buff[1] = value & 0x7F;
buff[2] = (value >> 7) & 0x7F; buff[2] = (value >> 7) & 0x7F;
@@ -326,7 +325,7 @@ firmata_analogRead(t_firmata *firmata, int pin)
{ {
int res; int res;
int value = 1; int value = 1;
uint8_t buff[2]; char buff[2];
buff[0] = FIRMATA_REPORT_ANALOG | pin; buff[0] = FIRMATA_REPORT_ANALOG | pin;
buff[1] = value; buff[1] = value;
res = mraa_uart_write(firmata->uart, buff, 2); res = mraa_uart_write(firmata->uart, buff, 2);
@@ -338,7 +337,7 @@ firmata_digitalWrite(t_firmata* firmata, int pin, int value)
{ {
int i; int i;
int res; int res;
uint8_t buff[4]; char buff[4];
if (pin < 0 || pin > 127) if (pin < 0 || pin > 127)
return (0); return (0);

View File

@@ -92,7 +92,7 @@ static mraa_result_t
mraa_firmata_i2c_init_bus_replace(mraa_i2c_context dev) mraa_firmata_i2c_init_bus_replace(mraa_i2c_context dev)
{ {
int delay = 1; // this should be either 1 or 0, I don't know :) 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[0] = FIRMATA_START_SYSEX;
buff[1] = FIRMATA_I2C_CONFIG; buff[1] = FIRMATA_I2C_CONFIG;
buff[2] = delay & 0xFF, (delay >> 8) & 0xFF; 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 static mraa_result_t
mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length) 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) { if (buffer == NULL) {
return MRAA_ERROR_NO_RESOURCES; 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 static mraa_result_t
mraa_firmata_send_i2c_read_reg_req(mraa_i2c_context dev, uint8_t command, int length) 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) { if (buffer == NULL) {
return MRAA_ERROR_NO_RESOURCES; 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 // buffer needs 5 bytes for firmata, and 2 bytes for every byte of data
int buffer_size = (bytesToWrite*2) + 5; int buffer_size = (bytesToWrite*2) + 5;
uint8_t* buffer = calloc(buffer_size, 0); char* buffer = calloc(buffer_size, 0);
if (buffer == NULL) { if (buffer == NULL) {
return MRAA_ERROR_NO_RESOURCES; 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 static mraa_result_t
mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data) 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) { if (buffer == NULL) {
return MRAA_ERROR_NO_RESOURCES; 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 static mraa_result_t
mraa_firmata_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command) 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) { if (buffer == NULL) {
return MRAA_ERROR_NO_RESOURCES; return MRAA_ERROR_NO_RESOURCES;
} }
@@ -517,6 +517,8 @@ mraa_firmata_pull_handler(void* vp)
isr_prev = isr_now; isr_prev = isr_now;
usleep(100); usleep(100);
} }
return NULL;
} }
mraa_board_t* mraa_board_t*