diff --git a/fsw/linux/libcan.c b/fsw/linux/libcan.c index 31fcdfa..2c935b3 100644 --- a/fsw/linux/libcan.c +++ b/fsw/linux/libcan.c @@ -216,7 +216,6 @@ int32_t can_close_device(can_info_t* device) int32_t can_master_transaction(can_info_t* device) { int32_t status; - uint8_t i; status = can_write(device); if (status != CAN_SUCCESS) @@ -233,6 +232,7 @@ int32_t can_master_transaction(can_info_t* device) } #ifdef LIBCAN_VERBOSE + uint8_t i; OS_printf("can_master_transaction: \n"); OS_printf(" can_id = 0x%08x \t tx: 0x", device->tx_frame.can_id); for (i = 0; i < device->tx_frame.can_dlc; i++) diff --git a/fsw/linux/libgpio.c b/fsw/linux/libgpio.c index b9c2797..2e92922 100644 --- a/fsw/linux/libgpio.c +++ b/fsw/linux/libgpio.c @@ -72,7 +72,7 @@ int32_t gpio_read(gpio_info_t* device, uint8_t* value) { int32_t status = GPIO_SUCCESS; char buffer[128]; - char readValue; + char readValue[3]; int fd; if(device->isOpen != GPIO_OPEN) @@ -95,8 +95,8 @@ int32_t gpio_read(gpio_info_t* device, uint8_t* value) } //convert from ASCII to decimal - if(readValue == '0') *value = 0; - else if(readValue == '1') *value = 1; + if(readValue[0] == '0') *value = 0; + else if(readValue[0] == '1') *value = 1; else { *value = 0; } diff --git a/fsw/linux/libi2c.c b/fsw/linux/libi2c.c index 6687c39..4ce6dbe 100644 --- a/fsw/linux/libi2c.c +++ b/fsw/linux/libi2c.c @@ -33,27 +33,27 @@ int32_t i2c_master_init(i2c_bus_info_t* device) device->handle = open(devname, O_RDWR); if (device->handle < 0) { - OS_printf("i2c bus open failed for handle = %d, %s\n", device->handle, strerror(errno)); + printf("i2c bus open failed for handle = %d, %s\n", device->handle, strerror(errno)); status = I2C_ERROR; device->isOpen = I2C_CLOSED; } else { device->isOpen = I2C_OPEN; - OS_printf("i2c bus open passed for handle = %d\n", device->handle); + printf("i2c bus open passed for handle = %d\n", device->handle); } return status; } -int32_t i2c_master_transaction(int32_t handle, uint8_t addr, void * txbuf, uint8_t txlen, void * rxbuf, uint8_t rxlen, uint16_t timeout) +int32_t i2c_master_transaction(i2c_bus_info_t* device, uint8_t addr, void * txbuf, uint8_t txlen, void * rxbuf, uint8_t rxlen, uint16_t timeout) { int32_t status = I2C_SUCCESS; int32_t resp; /* Set I2C slave address */ - if (ioctl(handle, I2C_SLAVE, addr) < 0) + if (ioctl(device->handle, I2C_SLAVE, addr) < 0) { - OS_printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; return status; } @@ -61,20 +61,20 @@ int32_t i2c_master_transaction(int32_t handle, uint8_t addr, void * txbuf, uint8 /* Perform write if needed */ if (txlen > 0 ) { - resp = write(handle, txbuf, txlen); + resp = write(device->handle, txbuf, txlen); if (resp != txlen) { - OS_printf("i2c-%d write to address 0x%X FAILED, [%u] %s\n", handle, addr, errno, strerror(errno)); + printf("i2c-%d write to address 0x%X FAILED, [%u] %s\n", device->handle, addr, errno, strerror(errno)); status = I2C_ERROR; } } /* Perform read if needed */ if (rxlen > 0 ) { - resp = read(handle, rxbuf, rxlen); + resp = read(device->handle, rxbuf, rxlen); if (resp != rxlen) { - OS_printf("i2c-%d read from address 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d read from address 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; } } @@ -82,69 +82,69 @@ int32_t i2c_master_transaction(int32_t handle, uint8_t addr, void * txbuf, uint8 return status; } -int32_t i2c_read_transaction(int32_t handle, uint8_t addr, void * rxbuf, uint8_t rxlen, uint8_t timeout) +int32_t i2c_read_transaction(i2c_bus_info_t* device, uint8_t addr, void * rxbuf, uint8_t rxlen, uint8_t timeout) { int32_t resp; int32_t status = I2C_SUCCESS; /* Set I2C slave address */ - if (ioctl(handle, I2C_SLAVE, addr) < 0) + if (ioctl(device->handle, I2C_SLAVE, addr) < 0) { - OS_printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; return status; } - resp = read(handle, rxbuf, rxlen); //<-- ACK would need to go in here + resp = read(device->handle, rxbuf, rxlen); //<-- ACK would need to go in here if (resp != rxlen) { - OS_printf("i2c-%d read from address 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d read from address 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; } return status; } -int32_t i2c_write_transaction(int32_t handle, uint8_t addr, void * txbuf, uint8_t txlen, uint8_t timeout) +int32_t i2c_write_transaction(i2c_bus_info_t* device, uint8_t addr, void * txbuf, uint8_t txlen, uint8_t timeout) { int32_t resp; int32_t status = I2C_SUCCESS; /* Set I2C slave address */ - if (ioctl(handle, I2C_SLAVE, addr) < 0) + if (ioctl(device->handle, I2C_SLAVE, addr) < 0) { - OS_printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; return status; } - resp = write(handle, txbuf, txlen); + resp = write(device->handle, txbuf, txlen); if (resp != txlen) { - OS_printf("i2c-%d write from address 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d write from address 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; } return status; } -int32_t i2c_multiple_transaction(int32_t handle, uint8_t addr, struct i2c_rdwr_ioctl_data* rdwr_data, uint16_t timeout) +int32_t i2c_multiple_transaction(i2c_bus_info_t* device, uint8_t addr, struct i2c_rdwr_ioctl_data* rdwr_data, uint16_t timeout) { /* Do combined read/write transaction without stop (simply restarts) in between. */ int32_t status = I2C_SUCCESS; /* Set I2C slave address */ - if (ioctl(handle, I2C_SLAVE, addr) < 0) + if (ioctl(device->handle, I2C_SLAVE, addr) < 0) { - OS_printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d setting slave address = 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; return status; } /* Make the ICOTL call */ - if (ioctl(handle, I2C_RDWR, rdwr_data) < 0) + if (ioctl(device->handle, I2C_RDWR, rdwr_data) < 0) { - OS_printf("i2c-%d multple transaction error = 0x%X FAILED, %s\n", handle, addr, strerror(errno)); + printf("i2c-%d multple transaction error = 0x%X FAILED, %s\n", device->handle, addr, strerror(errno)); status = I2C_ERROR; return status; } diff --git a/fsw/linux/libsocket.c b/fsw/linux/libsocket.c index 2966970..64f0474 100644 --- a/fsw/linux/libsocket.c +++ b/fsw/linux/libsocket.c @@ -172,7 +172,6 @@ int32_t socket_accept(socket_info_t* socket_info) int ret; struct sockaddr_in client; int32_t status; - int ip_str_len; status = SOCKET_SUCCESS; @@ -290,9 +289,7 @@ int32_t socket_send(socket_info_t* socket_info, uint8_t* buffer, size_t buflen, { int ret; int32_t status; - int address_family; struct sockaddr_in remote_sockaddr; - unsigned int i; status = SOCKET_SUCCESS; switch(socket_info->type) @@ -354,7 +351,6 @@ int32_t socket_recv(socket_info_t* socket_info, uint8_t* buffer, size_t buflen, { int c; int ret; - int ip_str_len; int32_t status; struct sockaddr_in remote_sockaddr; diff --git a/fsw/linux/libspi.c b/fsw/linux/libspi.c index d8f6d3e..340e9b5 100644 --- a/fsw/linux/libspi.c +++ b/fsw/linux/libspi.c @@ -15,7 +15,6 @@ NASA IV&V ivv-itc@lists.nasa.gov */ -#include "osapi.h" #include "libspi.h" spi_mutex_t spi_bus_mutex[MAX_SPI_BUSES]; diff --git a/fsw/linux/libtrq.c b/fsw/linux/libtrq.c index aeac317..8787132 100644 --- a/fsw/linux/libtrq.c +++ b/fsw/linux/libtrq.c @@ -37,21 +37,21 @@ int32_t trq_set_time_high(trq_info_t* device, uint32_t new_time) { if(!device->enabled) { - OS_printf("trq_set_time_high: Error setting trq %d timer period because it's disabled! \n", device->trq_num); + printf("trq_set_time_high: Error setting trq %d timer period because it's disabled! \n", device->trq_num); return TRQ_ERROR; } // Make sure the time high isn't greater than the period if(new_time > device->timer_period_ns) { - OS_printf("trq_set_time_high: Error setting trq %d time high, must not exceed the period! \n", device->trq_num); + printf("trq_set_time_high: Error setting trq %d time high, must not exceed the period! \n", device->trq_num); return TRQ_TIME_HIGH_VAL_ERR; } ioctl(device->timerfd, TMRCTR_PWM_DISABLE); if(ioctl(device->timerfd, TMRCTR_PWM_SET_HIGH_TIME, new_time) < 0) { - OS_printf("trq_set_time_high: Error setting trq %d high time! \n", device->trq_num); + printf("trq_set_time_high: Error setting trq %d high time! \n", device->trq_num); return TRQ_ERROR; } device->timer_high_ns = new_time; @@ -61,7 +61,7 @@ int32_t trq_set_time_high(trq_info_t* device, uint32_t new_time) ioctl(device->timerfd, TMRCTR_PWM_ENABLE); } - //OS_printf("trq_set_time_high: timer_period_ns = %d, timer_high_ns = %d\n", device->timer_period_ns, device->timer_high_ns); + //printf("trq_set_time_high: timer_period_ns = %d, timer_high_ns = %d\n", device->timer_period_ns, device->timer_high_ns); return TRQ_SUCCESS; } @@ -79,7 +79,7 @@ int32_t trq_set_period(trq_info_t* device) { if(!device->enabled) { - OS_printf("trq_set_period: Error setting trq %d timer period because it's disabled! \n", device->trq_num); + printf("trq_set_period: Error setting trq %d timer period because it's disabled! \n", device->trq_num); return TRQ_ERROR; } @@ -88,7 +88,7 @@ int32_t trq_set_period(trq_info_t* device) if(ioctl(device->timerfd, TMRCTR_PWM_SET_PERIOD, device->timer_period_ns) < 0) { - OS_printf("trq_set_period: Error setting trq %d timer period! \n", device->trq_num); + printf("trq_set_period: Error setting trq %d timer period! \n", device->trq_num); return TRQ_ERROR; } @@ -125,7 +125,7 @@ int32_t trq_set_direction(trq_info_t* device, bool direction) if (write(device->direction_pin_fd, &charVal, 1) != 1) { - OS_printf("trq_set_direction: Error setting trq %d direction! \n", device->trq_num); + printf("trq_set_direction: Error setting trq %d direction! \n", device->trq_num); return TRQ_ERROR; } device->positive_direction = direction; @@ -148,7 +148,6 @@ int32_t trq_init(trq_info_t* device) { int32_t status = TRQ_SUCCESS; char devname[TRQ_FNAME_SIZE]; - char pinname[TRQ_FNAME_SIZE]; if(!device->enabled) { @@ -156,7 +155,7 @@ int32_t trq_init(trq_info_t* device) snprintf(devname, TRQ_FNAME_SIZE, "/dev/tmrctr%d", device->trq_num); if((device->timerfd = open(devname, O_RDWR, 0)) < 0) { - OS_printf("trq_init: Error opening axi timer device %s \n", devname); + printf("trq_init: Error opening axi timer device %s \n", devname); return TRQ_INIT_ERR; } //printf("trq_init: Initialized AXI Timer Device: %s for device->trq_num %d \n", devname, device->trq_num); @@ -165,7 +164,7 @@ int32_t trq_init(trq_info_t* device) snprintf(devname, TRQ_FNAME_SIZE, "/dev/hb%d", device->trq_num); if((device->direction_pin_fd = open(devname, O_RDWR, 0)) < 0) { - OS_printf("trq_init: Error opening axi timer device %s \n", devname); + printf("trq_init: Error opening axi timer device %s \n", devname); return TRQ_INIT_ERR; } @@ -175,7 +174,6 @@ int32_t trq_init(trq_info_t* device) { return TRQ_INIT_ERR; } - //OS_printf("trq_init: Initialized direction pin: %s for device->trq_num %d\n", pinname, device->trq_num); device->enabled = true; } @@ -214,7 +212,6 @@ int32_t trq_command(trq_info_t *device, uint8_t percent_high, bool pos_dir) { int32_t status = TRQ_SUCCESS; uint32_t time_high_ns; - char charVal; if(!device->enabled) { @@ -225,7 +222,7 @@ int32_t trq_command(trq_info_t *device, uint8_t percent_high, bool pos_dir) // Calculate time high if (percent_high > 100) { - OS_printf("trq_command: Error setting percent high greater than 100! \n"); + printf("trq_command: Error setting percent high greater than 100! \n"); return TRQ_ERROR; } time_high_ns = device->timer_period_ns * (percent_high / 100.00); @@ -249,7 +246,7 @@ int32_t trq_command(trq_info_t *device, uint8_t percent_high, bool pos_dir) status = trq_set_direction(device, pos_dir); if(status != TRQ_SUCCESS) { - OS_printf("trq_command: Error setting trq %d direction! \n", device->trq_num); + printf("trq_command: Error setting trq %d direction! \n", device->trq_num); status = TRQ_INIT_ERR; return status; } @@ -269,7 +266,7 @@ void trq_close(trq_info_t* device) { if(!device->enabled) { - OS_printf("trq_close: Error closing trq %d, already disabled! \n", device->trq_num); + printf("trq_close: Error closing trq %d, already disabled! \n", device->trq_num); return; } diff --git a/fsw/linux/libuart.c b/fsw/linux/libuart.c index 46c2fd9..fbbb87f 100644 --- a/fsw/linux/libuart.c +++ b/fsw/linux/libuart.c @@ -130,7 +130,7 @@ int32_t uart_init_port(uart_info_t* device) // Set the port to blocking read with timeout of 0.1 sec device->options.c_cc[VMIN] = 0; // min of bytes to read device->options.c_cc[VTIME] = 1; // intra-byte time to wait - tenths of sec - fcntl(device->handle, F_SETFL, 0); // Have serial port block + fcntl(device->handle, F_SETFL, O_NONBLOCK); // Don't have serial port block // TODO - any other options needed like hw control? tcflush(device->handle, TCIOFLUSH); @@ -144,7 +144,7 @@ int32_t uart_init_port(uart_info_t* device) } else { - OS_printf("Oh no! Open \"%s\" failed and reported: %s \n", device->deviceString, strerror(device->handle)); + printf("Oh no! Open \"%s\" failed and reported: %s \n", device->deviceString, strerror(device->handle)); device->isOpen = PORT_CLOSED; status = OS_ERR_FILE; } @@ -152,23 +152,23 @@ int32_t uart_init_port(uart_info_t* device) return status; } -int32_t uart_bytes_available(int32_t handle) +int32_t uart_bytes_available(uart_info_t* device) { int32_t bytes_available = 0; - ioctl(handle, FIONREAD, &bytes_available); + ioctl(device->handle, FIONREAD, &bytes_available); return bytes_available; } -int32_t uart_flush(int32_t handle) +int32_t uart_flush(uart_info_t* device) { - tcflush(handle,TCIOFLUSH); + tcflush(device->handle,TCIOFLUSH); return UART_SUCCESS; } -int32_t uart_read_port(int32_t handle, uint8_t data[], const uint32_t numBytes) +int32_t uart_read_port(uart_info_t* device, uint8_t data[], const uint32_t numBytes) { int32_t status = UART_SUCCESS; @@ -176,7 +176,7 @@ int32_t uart_read_port(int32_t handle, uint8_t data[], const uint32_t numBytes) { // TODO - this read blocks forever if no serial data on the port. // it should be timing out - need to look into this ASAP - status = read(handle, data, numBytes); + status = read(device->handle, data, numBytes); } else { @@ -186,22 +186,22 @@ int32_t uart_read_port(int32_t handle, uint8_t data[], const uint32_t numBytes) return status; } -int32_t uart_write_port(int32_t handle, uint8_t data[], const uint32_t numBytes) +int32_t uart_write_port(uart_info_t* device, uint8_t data[], const uint32_t numBytes) { int32_t status = UART_SUCCESS; - status = write(handle, data, numBytes); + status = write(device->handle, data, numBytes); return status; } -int32_t uart_close_port(int32_t handle) +int32_t uart_close_port(uart_info_t* device) { int32_t status = UART_SUCCESS; - if (handle >= 0) + if (device->handle >= 0) { - status = close(handle); + status = close(device->handle); if (0 == status) /* todo remove magic number */ { status = UART_SUCCESS; diff --git a/fsw/public_inc/hwlib.h b/fsw/public_inc/hwlib.h index 702aed8..ca52643 100644 --- a/fsw/public_inc/hwlib.h +++ b/fsw/public_inc/hwlib.h @@ -38,6 +38,8 @@ ivv-itc@lists.nasa.gov ** Outside of cFS build *************************************************************************/ #ifndef OS_SUCCESS + #pragma GCC diagnostic ignored "-Wall" + #pragma GCC diagnostic warning "-Wunused-value" #define OS_printf printf #define OS_TaskDelay(n) ( usleep((n) * 1000) ) #if defined (__GNUC__) diff --git a/fsw/src/hwlib.c b/fsw/src/hwlib.c index e767df8..4bfce8a 100644 --- a/fsw/src/hwlib.c +++ b/fsw/src/hwlib.c @@ -53,10 +53,15 @@ ivv-itc@lists.nasa.gov int32 hwlib_Init(void) { /* - ** Register the events - */ + ** Register the events + */ CFE_EVS_Register(NULL, 0, CFE_EVS_NO_FILTER); + /* + ** Resolve statement with no effect + */ + + /* ** Init all hardware subsystems and interfaces ** order may be important.