aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/microblaze/apps/txrx_uhd.c19
-rw-r--r--firmware/microblaze/lib/hal_io.c21
-rw-r--r--firmware/microblaze/lib/hal_io.h2
-rw-r--r--firmware/microblaze/lib/hal_uart.c2
-rw-r--r--host/lib/usrp/usrp2/fw_common.h11
5 files changed, 54 insertions, 1 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c
index f0a9702be..42a3f4b89 100644
--- a/firmware/microblaze/apps/txrx_uhd.c
+++ b/firmware/microblaze/apps/txrx_uhd.c
@@ -311,6 +311,25 @@ void handle_udp_ctrl_packet(
ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE;
break;
+ case USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO:{
+ //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(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_in->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;
+ }
+
+ case USRP2_CTRL_ID_HEY_WRITE_THIS_UART_FOR_ME_BRO:{
+ int num_bytes = ctrl_data_in->data.uart_args.bytes;
+ if(num_bytes > 20) num_bytes = 20;
+ fnputstr(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_in->data.uart_args.data, num_bytes);
+ ctrl_data_out.id = USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE;
+ ctrl_data_out.data.i2c_args.bytes = num_bytes;
+ break;
+ }
+
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
diff --git a/firmware/microblaze/lib/hal_io.c b/firmware/microblaze/lib/hal_io.c
index 8bb5e2af8..549990311 100644
--- a/firmware/microblaze/lib/hal_io.c
+++ b/firmware/microblaze/lib/hal_io.c
@@ -206,6 +206,18 @@ fputstr(hal_uart_name_t u, const char *s)
}
int
+fnputstr(hal_uart_name_t u, const char *s, int len)
+{
+ int x;
+ while (*s && (len > x)) {
+ fputchar(u, *s++);
+ x++;
+ }
+
+ return x;
+}
+
+int
putstr(const char *s)
{
return fputstr(DEFAULT_UART, s);
@@ -233,6 +245,15 @@ fgets(hal_uart_name_t u, char * const s)
return s;
}
+int
+fngets(hal_uart_name_t u, char * const s, int len)
+{
+ char *x = s;
+ while(((*x=(char)hal_uart_getc(u)) != '\n') && ((x-s) < len)) x++;
+ *x = 0;
+ return (x-s)-1;
+}
+
char *
gets(char * const s)
{
diff --git a/firmware/microblaze/lib/hal_io.h b/firmware/microblaze/lib/hal_io.h
index 99f8f7fc9..45e23755f 100644
--- a/firmware/microblaze/lib/hal_io.h
+++ b/firmware/microblaze/lib/hal_io.h
@@ -26,6 +26,8 @@ void hal_io_init(void);
void hal_finish();
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);
/*
* ------------------------------------------------------------------------
diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/microblaze/lib/hal_uart.c
index 6717cd5e8..c85bcaca3 100644
--- a/firmware/microblaze/lib/hal_uart.c
+++ b/firmware/microblaze/lib/hal_uart.c
@@ -47,7 +47,7 @@ static char uart_mode[4] = {
static char uart_speeds[4] = {
[UART_DEBUG] = US_230400,
[UART_EXP] = US_230400,
- [UART_GPS] = US_230400
+ [UART_GPS] = US_115200
};
void
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 85d41d57f..fc1e6f2a7 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -83,6 +83,12 @@ typedef enum{
USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO = 'r',
USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE = 'R',
+ USRP2_CTRL_ID_HEY_WRITE_THIS_UART_FOR_ME_BRO = 'u',
+ USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE = 'U',
+
+ USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO = 'v',
+ USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE = 'V',
+
USRP2_CTRL_ID_PEACE_OUT = '~'
} usrp2_ctrl_id_t;
@@ -123,6 +129,11 @@ typedef struct{
__stdint(uint32_t) datahi;
__stdint(uint8_t) num_bytes; //1, 2, 4, 8
} poke_args;
+ struct {
+ __stdint(uint8_t) dev;
+ __stdint(uint8_t) bytes;
+ __stdint(uint8_t) data[20];
+ } uart_args;
} data;
} usrp2_ctrl_data_t;