summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-04-21 17:49:00 -0700
committerJosh Blum <josh@joshknows.com>2010-04-21 17:49:00 -0700
commite5248746f66829c0bd899bcde5c15970fdda785d (patch)
treeb2b0bab970610737ff4710e508dd5a9c04c92869 /firmware
parent72f4ce79c88d03b33d585a2ea48076e2010a21a8 (diff)
downloaduhd-e5248746f66829c0bd899bcde5c15970fdda785d.tar.gz
uhd-e5248746f66829c0bd899bcde5c15970fdda785d.tar.bz2
uhd-e5248746f66829c0bd899bcde5c15970fdda785d.zip
Added protocol version number to usrp2 common header and data struct.
Diffstat (limited to 'firmware')
-rw-r--r--firmware/microblaze/apps/txrx.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx.c
index 2e13a99d0..d2497892b 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx.c
@@ -201,20 +201,34 @@ void handle_udp_ctrl_packet(
unsigned char *payload, int payload_len
){
//printf("Got ctrl packet #words: %d\n", (int)payload_len);
+ usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload;
+ uint32_t ctrl_data_in_id = ctrl_data_in->id;
+
+ //ensure that the protocol versions match
+ if (payload_len >= sizeof(uint32_t) && ctrl_data_in->proto_ver != USRP2_PROTO_VERSION){
+ printf("!Error in control packet handler: Expected protocol version %d, but got %d\n",
+ USRP2_PROTO_VERSION, ctrl_data_in->proto_ver
+ );
+ ctrl_data_in_id = USRP2_CTRL_ID_GIVE_ME_YOUR_IP_ADDR_BRO;
+ }
+
+ //ensure that this is not a short packet
if (payload_len < sizeof(usrp2_ctrl_data_t)){
- //TODO send err packet
- return;
+ printf("!Error in control packet handler: Expected payload length %d, but got %d\n",
+ (int)sizeof(usrp2_ctrl_data_t), payload_len
+ );
+ ctrl_data_in_id = USRP2_CTRL_ID_HUH_WHAT;
}
- //setup the input and output data
- usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload;
+ //setup the output data
usrp2_ctrl_data_t ctrl_data_out = {
+ .proto_ver = USRP2_PROTO_VERSION,
.id=USRP2_CTRL_ID_HUH_WHAT,
.seq=ctrl_data_in->seq
};
//handle the data based on the id
- switch(ctrl_data_in->id){
+ switch(ctrl_data_in_id){
/*******************************************************************
* Addressing
@@ -400,6 +414,15 @@ void handle_udp_ctrl_packet(
ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE;
break;
+ /*******************************************************************
+ * Hardware Rev Numbers
+ ******************************************************************/
+ case USRP2_CTRL_ID_WHATS_THE_HARDWARE_REV_NOS_BRO:
+ ctrl_data_out.data.hw_rev.major = u2_hw_rev_major;
+ ctrl_data_out.data.hw_rev.minor = u2_hw_rev_minor;
+ ctrl_data_out.id = USRP2_CTRL_ID_TAKE_THE_HARDWARE_REV_NOS_DUDE;
+ break;
+
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
@@ -572,6 +595,7 @@ main(void)
print_mac_addr(ethernet_mac_addr()->addr);
newline();
print_ip_addr(get_ip_addr()); newline();
+ printf("Control protocol version: %d\n", USRP2_PROTO_VERSION);
ethernet_register_link_changed_callback(link_changed_callback);
ethernet_init();