From f3143f23926c64a8683a89991b263f0c9b1c8aeb Mon Sep 17 00:00:00 2001 From: "Lucas, John P." Date: Mon, 1 Jul 2024 14:47:32 -0400 Subject: [PATCH 1/2] [nasa/nos3#176] Updates to resolve build issues with linux version and added pragma for unit tests in hwlib.h; --- fsw/linux/libcan.c | 2 +- fsw/linux/libgpio.c | 6 +++--- fsw/linux/libi2c.c | 48 +++++++++++++++++++++--------------------- fsw/linux/libsocket.c | 4 ---- fsw/linux/libspi.c | 1 - fsw/linux/libtrq.c | 27 +++++++++++------------- fsw/linux/libuart.c | 26 +++++++++++------------ fsw/public_inc/hwlib.h | 2 ++ fsw/src/hwlib.c | 9 ++++++-- 9 files changed, 62 insertions(+), 63 deletions(-) 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. From f2e180cc30a883660ec70a3fb5391f4eb86a2f29 Mon Sep 17 00:00:00 2001 From: "Lucas, John P." Date: Wed, 31 Jul 2024 10:41:51 -0400 Subject: [PATCH 2/2] [nasa/nos3#176] Created quick stubs to further enable unit testing; --- fsw/stubs/libcan.c | 58 ++++++++++++++++++++ fsw/stubs/libgpio.c | 38 +++++++++++++ fsw/stubs/libi2c.c | 50 +++++++++++++++++ fsw/stubs/libsocket.c | 83 ++++++++++++++++++++++++++++ fsw/stubs/libspi.c | 60 ++++++++++++++++++++ fsw/stubs/libtrq.c | 116 +++++++++++++++++++++++++++++++++++++++ fsw/stubs/libtrq_ioctl.h | 42 ++++++++++++++ fsw/stubs/libuart.c | 48 ++++++++++++++++ 8 files changed, 495 insertions(+) create mode 100644 fsw/stubs/libcan.c create mode 100644 fsw/stubs/libgpio.c create mode 100644 fsw/stubs/libi2c.c create mode 100644 fsw/stubs/libsocket.c create mode 100644 fsw/stubs/libspi.c create mode 100644 fsw/stubs/libtrq.c create mode 100644 fsw/stubs/libtrq_ioctl.h create mode 100644 fsw/stubs/libuart.c diff --git a/fsw/stubs/libcan.c b/fsw/stubs/libcan.c new file mode 100644 index 0000000..c65b690 --- /dev/null +++ b/fsw/stubs/libcan.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2009 - 2019 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include "libcan.h" + +/* The `libsocketcan` library wraps many of the netlink operations to control a SocketCAN interface + * Documentation here: https://lalten.github.io/libsocketcan/Documentation/html/group__extern.html */ + +// Bring CAN network interface +int32_t can_init_dev(can_info_t* device) +{ + return CAN_SUCCESS; +} + +// Call the `libsocketcan` function to set each CAN mode on/off +int32_t can_set_modes(can_info_t* device) +{ + return CAN_SUCCESS; +} + +// Write a can_frame from `device->tx_Frame` to CAN bus from SocketCAN socket specified by `device` +int32_t can_write(can_info_t* device) +{ + return CAN_SUCCESS; +} + +// Read a can_frame from SocketCAN interface specified by `device` into `device->rx_frame` +// Does a nonblocking read call +int32_t can_read(can_info_t* device) +{ + return CAN_SUCCESS; +} + +// Bring CAN network interface down +int32_t can_close_device(can_info_t* device) +{ + return CAN_SUCCESS; +} + +// Perform non-blocking can transaction +int32_t can_master_transaction(can_info_t* device) +{ + return CAN_SUCCESS; +} diff --git a/fsw/stubs/libgpio.c b/fsw/stubs/libgpio.c new file mode 100644 index 0000000..747d3aa --- /dev/null +++ b/fsw/stubs/libgpio.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2009 - 2019 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include "libgpio.h" + +int32_t gpio_init(gpio_info_t* device) +{ + return GPIO_SUCCESS; +} + +int32_t gpio_read(gpio_info_t* device, uint8_t* value) +{ + return GPIO_SUCCESS; +} + +int32_t gpio_write(gpio_info_t* device, uint8_t value) +{ + return GPIO_SUCCESS; +} + +int32_t gpio_close(gpio_info_t* device) +{ + return GPIO_SUCCESS; +} diff --git a/fsw/stubs/libi2c.c b/fsw/stubs/libi2c.c new file mode 100644 index 0000000..c0b99a2 --- /dev/null +++ b/fsw/stubs/libi2c.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2009 - 2018 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include +#include + +#include "libi2c.h" + +/* Call to configure a specific i2c device from /dev +** i2c_bus- struct with bus configuration +** speed - currently unused +*/ +int32_t i2c_master_init(i2c_bus_info_t* device) +{ + return I2C_SUCCESS; +} + +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) +{ + return I2C_SUCCESS; +} + +int32_t i2c_read_transaction(i2c_bus_info_t* device, uint8_t addr, void * rxbuf, uint8_t rxlen, uint8_t timeout) +{ + return I2C_SUCCESS; +} + +int32_t i2c_write_transaction(i2c_bus_info_t* device, uint8_t addr, void * txbuf, uint8_t txlen, uint8_t timeout) +{ + return I2C_SUCCESS; +} + +int32_t i2c_multiple_transaction(i2c_bus_info_t* device, uint8_t addr, struct i2c_rdwr_ioctl_data* rdwr_data, uint16_t timeout) +{ + return I2C_SUCCESS; +} diff --git a/fsw/stubs/libsocket.c b/fsw/stubs/libsocket.c new file mode 100644 index 0000000..32298fb --- /dev/null +++ b/fsw/stubs/libsocket.c @@ -0,0 +1,83 @@ +#include "libsocket.h" + +#include +#include +#include +#include + +// Creates an endpoint for communication +// Binds stream, server sockets to localhost and port number +// +// Inputs: +// socket_info->address_family +// socket_info->type +// socket_info->port_num (used for stream sockets) +// socket_info->block +// +// Outputs: +// socket_info->sockfd +// socket_info->created +// socket_info->bound +int32_t socket_create(socket_info_t* socket_info) +{ + return SOCKET_SUCCESS; +} + +// Listens on a connection on a socket +// +// Inputs: +// socket_info->bound +// socket_info->sockfd +// +// Outputs: +// socket_info->listening +int32_t socket_listen(socket_info_t* socket_info) +{ + return SOCKET_SUCCESS; +} + +// Accepts a connection on a socket +// +// Inputs: +// socket_info->listening +// socket_info->sockfd +// +// Outputs: +// socket_info->connected +// socket_info->sockfd +int32_t socket_accept(socket_info_t* socket_info) +{ + return SOCKET_SUCCESS; +} + +// Initiates a connection to a remote ip address and port number +// +// Inputs: +// socket_info->created +// socket_info->category +// socket_info->address_family +// socket_info->sockfd +// remote_ip_address (the remote ip address) +// remote_port_num (the remote port number) +// +// Outputs: +// socket_info->connected +int32_t socket_connect(socket_info_t* socket_info, char* remote_ip_address, int remote_port_num) +{ + return SOCKET_SUCCESS; +} + +int32_t socket_send(socket_info_t* socket_info, uint8_t* buffer, size_t buflen, size_t* bytes_sent, char* remote_ip_address, int remote_port_num) +{ + return SOCKET_SUCCESS; +} + +int32_t socket_recv(socket_info_t* socket_info, uint8_t* buffer, size_t buflen, size_t* bytes_recvd) +{ + return SOCKET_SUCCESS; +} + +int32_t socket_close(socket_info_t* socket_info) +{ + return SOCKET_SUCCESS; +} diff --git a/fsw/stubs/libspi.c b/fsw/stubs/libspi.c new file mode 100644 index 0000000..e3d88cd --- /dev/null +++ b/fsw/stubs/libspi.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2009 - 2018 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include "libspi.h" + +spi_mutex_t spi_bus_mutex[MAX_SPI_BUSES]; + +int32_t spi_init_dev(spi_info_t* device) +{ + return SPI_SUCCESS; +} + +int32_t spi_set_mode(spi_info_t* device) +{ + return SPI_SUCCESS; +} + +int32_t spi_get_mode(spi_info_t* device) +{ + return SPI_SUCCESS; +} + +int32_t spi_write(spi_info_t* device, uint8_t data[], const uint32_t numBytes) +{ + return SPI_SUCCESS; +} + +int32_t spi_read(spi_info_t* device, uint8_t data[], const uint32_t numBytes) +{ + return SPI_SUCCESS; +} + +int32_t spi_transaction(spi_info_t* device, uint8_t *txBuff, uint8_t * rxBuffer, uint32_t length, uint16_t delay, uint8_t bits, uint8_t deselect) +{ + return SPI_SUCCESS; +} + +int32_t spi_select_chip(spi_info_t* device) +{ + return SPI_SUCCESS; +} + +int32_t spi_close_device(spi_info_t* device) +{ + return SPI_SUCCESS; +} diff --git a/fsw/stubs/libtrq.c b/fsw/stubs/libtrq.c new file mode 100644 index 0000000..215fcd1 --- /dev/null +++ b/fsw/stubs/libtrq.c @@ -0,0 +1,116 @@ +/* Copyright (C) 2009 - 2019 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include +#include "libtrq.h" +#include "libtrq_ioctl.h" + +#define TRQ_FNAME_SIZE 50 + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_set_time_high(): Configure the time high per period in nanoseconds for a TRQ device. Time high lengths + * may not exceed a device's period length. + * + * Inputs: trq_info_t *device - TRQ device info structure + * uint32_t new_time - New time high length for the device period in nanoseconds + * + * Outputs: trq_info_t *device - High time set to new_time if successful + * returns int32_t - TRQ_ERROR_* type on failure, TRQ_SUCCESS on success + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32_t trq_set_time_high(trq_info_t* device, uint32_t new_time) +{ + return TRQ_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_set_period(): Configure the period length for a TRQ device in nanoseconds. Note that timer time high + * is set to zero before this function is called. + * + * Inputs: trq_info_t *device - TRQ device info structure + * + * Outputs: returns int32_t - TRQ_ERROR on failure, TRQ_SUCCESS on success + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32_t trq_set_period(trq_info_t* device) +{ + return TRQ_SUCCESS; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_set_direction(): Configure the direction of the TRQ device. + * + * Inputs: trq_info_t *device - TRQ device info structure + * bool direction - New direction desired for device + * + * Outputs: trq_info_t *device - positive_direction set to direction if successful + * returns int32_t - TRQ_ERROR on failure, TRQ_SUCCESS on success + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32_t trq_set_direction(trq_info_t* device, bool direction) +{ + return TRQ_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_init(): Opens a TRQ device and initializes it. This function can also be + * used on an already opened TRQ number to reset it. + * + * Inputs: trq_info_t *device - TRQ Device info structure to initialize + * + * Outputs: trq_info_t *device - Info structure contains AXI timer device file descriptor. + * returns int32_t - <0 on failure, TRQ_SUCCESS on success + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32_t trq_init(trq_info_t* device) +{ + return TRQ_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_command(): Change TQR period, time high, or direction. + * + * Inputs: trq_info_t* device - TQR device info structure to modify + * uint8_t percent_high - Percent of the period to be high (0-100) + * bool pos_dir - Direction - True for positive, False for negative + * + * Outputs: trq_info_t *device - Parameters set to new values if successful + * returns int32_t - TRQ_ERROR_* type on failure, TRQ_SUCCESS on success + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32_t trq_command(trq_info_t *device, uint8_t percent_high, bool pos_dir) +{ + return TRQ_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * trq_close(): Disables and closes an active TRQ device. + * + * Inputs: trq_info_t *device - TRQ device info structure for TRQ device to disable + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void trq_close(trq_info_t* device) +{ + return TRQ_SUCCESS; +} diff --git a/fsw/stubs/libtrq_ioctl.h b/fsw/stubs/libtrq_ioctl.h new file mode 100644 index 0000000..e3ba0ea --- /dev/null +++ b/fsw/stubs/libtrq_ioctl.h @@ -0,0 +1,42 @@ +/* Copyright (C) 2009 - 2019 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + + +/* IOCTL commands */ +#include + +#define TMRCTR_MAGIC 15 + +#define TMRCTR_START _IO( TMRCTR_MAGIC, 0 ) +#define TMRCTR_STOP _IO( TMRCTR_MAGIC, 1 ) +#define TMRCTR_PWM_ENABLE _IO( TMRCTR_MAGIC, 2 ) +#define TMRCTR_PWM_SET_PERIOD _IOW( TMRCTR_MAGIC, 3, long) +#define TMRCTR_PWM_SET_HIGH_TIME _IOW( TMRCTR_MAGIC, 4, long) +#define TMRCTR_PWM_DISABLE _IO( TMRCTR_MAGIC, 5 ) +#define TMRCTR_SELFTEST _IO( TMRCTR_MAGIC, 6 ) +#define TMRCTR_SETOPTION _IOW( TMRCTR_MAGIC, 7, long) +#define TMRCTR_GETOPTION _IOR( TMRCTR_MAGIC, 8, long) +#define TMRCTR_RESET _IO( TMRCTR_MAGIC, 9 ) +#define TMRCTR_SET_RESET_VALUE _IOW( TMRCTR_MAGIC, 10, long) +#define TMRCTR_GET_VALUE _IOR( TMRCTR_MAGIC, 11, long) +#define TMRCTR_GET_CAPTURE_VALUE _IOR( TMRCTR_MAGIC, 12, long) +#define TMRCTR_CHECK_UPDATE _IOR( TMRCTR_MAGIC, 13, long) +#define TMRCTR_TMR_SELECT _IOW( TMRCTR_MAGIC, 14, long) + +/* IOCTL Errors */ +#define TMRCTR_BAD_CMD (-1) + diff --git a/fsw/stubs/libuart.c b/fsw/stubs/libuart.c new file mode 100644 index 0000000..e9bfc17 --- /dev/null +++ b/fsw/stubs/libuart.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2009 - 2018 National Aeronautics and Space Administration. All Foreign Rights are Reserved to the U.S. Government. + +This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including, but not +limited to, any warranty that the software will conform to, specifications any implied warranties of merchantability, fitness +for a particular purpose, and freedom from infringement, and any warranty that the documentation will conform to the program, or +any warranty that the software will be error free. + +In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or consequential damages, +arising out of, resulting from, or in any way connected with the software or its documentation. Whether or not based upon warranty, +contract, tort or otherwise, and whether or not loss was sustained from, or arose out of the results of, or use of, the software, +documentation or services provided hereunder + +ITC Team +NASA IV&V +ivv-itc@lists.nasa.gov +*/ + +#include "libuart.h" + +int32_t uart_init_port(uart_info_t* device) +{ + return UART_SUCCESS; +} + +int32_t uart_bytes_available(uart_info_t* device) +{ + return 1; +} + +int32_t uart_flush(uart_info_t* device) +{ + return UART_SUCCESS; +} + +int32_t uart_read_port(uart_info_t* device, uint8_t data[], const uint32_t numBytes) +{ + return numBytes; +} + +int32_t uart_write_port(uart_info_t* device, uint8_t data[], const uint32_t numBytes) +{ + return numBytes; +} + +int32_t uart_close_port(uart_info_t* device) +{ + return UART_SUCCESS; +}