diff options
-rw-r--r-- | firmware/zpu/apps/txrx_uhd.c | 2 | ||||
-rw-r--r-- | firmware/zpu/lib/hal_io.c | 4 | ||||
-rw-r--r-- | firmware/zpu/lib/hal_io.h | 2 | ||||
-rw-r--r-- | firmware/zpu/lib/hal_uart.c | 11 | ||||
-rw-r--r-- | firmware/zpu/lib/hal_uart.h | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/gps_ctrl.cpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 2 |
7 files changed, 15 insertions, 15 deletions
diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c index 61a2c1f76..4ccb585e2 100644 --- a/firmware/zpu/apps/txrx_uhd.c +++ b/firmware/zpu/apps/txrx_uhd.c @@ -230,7 +230,7 @@ static void handle_udp_ctrl_packet( //executes a readline()-style read, up to num_bytes long, up to and including newline int num_bytes = ctrl_data_in->data.uart_args.bytes; if(num_bytes > 20) num_bytes = 20; - num_bytes = fngets_timeout(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes); + num_bytes = fngets_noblock(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes); ctrl_data_out.id = USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE; ctrl_data_out.data.uart_args.bytes = num_bytes; break; diff --git a/firmware/zpu/lib/hal_io.c b/firmware/zpu/lib/hal_io.c index be4c570c7..1d137943c 100644 --- a/firmware/zpu/lib/hal_io.c +++ b/firmware/zpu/lib/hal_io.c @@ -253,11 +253,11 @@ fngets(hal_uart_name_t u, char * const s, int len) } int -fngets_timeout(hal_uart_name_t u, char * const s, int len) +fngets_noblock(hal_uart_name_t u, char * const s, int len) { char *x = s; - while(((*x=(char)hal_uart_getc_timeout(u)) != '\n') && (*x != -1) && ((x-s) < len)) x++; + while(((*x=(char)hal_uart_getc_noblock(u)) != '\n') && (*x != 255) && ((x-s) < len)) x++; *x = 0; //printf("Returning from fngets() with string %d of length %d\n", s[0], x-s); return (x-s); diff --git a/firmware/zpu/lib/hal_io.h b/firmware/zpu/lib/hal_io.h index 574df7d3e..7a617685c 100644 --- a/firmware/zpu/lib/hal_io.h +++ b/firmware/zpu/lib/hal_io.h @@ -28,7 +28,7 @@ char *gets(char * const s); int fputstr(hal_uart_name_t u, const char *s); int fnputstr(hal_uart_name_t u, const char *s, int len); int fngets(hal_uart_name_t u, char * const s, int len); -int fngets_timeout(hal_uart_name_t u, char * const s, int len); +int fngets_noblock(hal_uart_name_t u, char * const s, int len); /* * ------------------------------------------------------------------------ diff --git a/firmware/zpu/lib/hal_uart.c b/firmware/zpu/lib/hal_uart.c index f0921f4f0..6a37cceb6 100644 --- a/firmware/zpu/lib/hal_uart.c +++ b/firmware/zpu/lib/hal_uart.c @@ -103,12 +103,13 @@ hal_uart_getc(hal_uart_name_t u) } int -hal_uart_getc_timeout(hal_uart_name_t u) +hal_uart_getc_noblock(hal_uart_name_t u) { - int timeout = 0; - while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS)) - mdelay(1); - return (timeout >= HAL_UART_TIMEOUT_MS) ? -1 : uart_regs[u].rxchar; //return -1 if nothing there, cause fngets to quit +// int timeout = 0; +// while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS)) +// mdelay(1); + if(uart_regs[u].rxlevel == 0) return 255; + return uart_regs[u].rxchar; } int hal_uart_rx_flush(hal_uart_name_t u) diff --git a/firmware/zpu/lib/hal_uart.h b/firmware/zpu/lib/hal_uart.h index 758c8cb5e..793aface0 100644 --- a/firmware/zpu/lib/hal_uart.h +++ b/firmware/zpu/lib/hal_uart.h @@ -27,8 +27,6 @@ #define DEFAULT_UART UART_DEBUG //which UART printf, gets, etc. use -#define HAL_UART_TIMEOUT_MS 300 - typedef enum { US_9600 = 0, US_19200 = 1, @@ -85,9 +83,9 @@ void hal_uart_putc_nowait(hal_uart_name_t u, int ch); int hal_uart_getc(hal_uart_name_t u); /* - * \brief Blocking read of next char from serial port with timeout + * \brief Non-blocking read of next char from serial port, return -1 if nothing available */ -int hal_uart_getc_timeout(hal_uart_name_t u); +int hal_uart_getc_noblock(hal_uart_name_t u); int hal_uart_rx_flush(hal_uart_name_t u); diff --git a/host/lib/usrp/usrp2/gps_ctrl.cpp b/host/lib/usrp/usrp2/gps_ctrl.cpp index 2273b2cd9..9f9b27954 100644 --- a/host/lib/usrp/usrp2/gps_ctrl.cpp +++ b/host/lib/usrp/usrp2/gps_ctrl.cpp @@ -60,13 +60,14 @@ public: } else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); } if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA; //otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later) if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) { - std::cout << "Invalid reply, possible incorrect baud rate" << std::endl; + std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl; } bool found_gprmc = false; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 6d5652e9e..95a3819b3 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -65,7 +65,7 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); - //_gps_ctrl = usrp2_gps_ctrl::make(_iface); + _gps_ctrl = usrp2_gps_ctrl::make(_iface); //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; |