Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
Revision 19:8c1f2a2204fb, committed 2014-04-20
- Comitter:
- krobertson
- Date:
- Sun Apr 20 22:01:05 2014 +0000
- Parent:
- 18:e72ee7aed088
- Child:
- 20:81d5655fecc2
- Commit message:
- downlink seems to be reliable now
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
packet.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Apr 20 08:04:37 2014 +0000 +++ b/main.cpp Sun Apr 20 22:01:05 2014 +0000 @@ -145,26 +145,20 @@ __disable_irq(); XBEE::getTCPInterrupt().fall(&connection_lost); - getPS().wait_for_egg(); + getPS().openConnection(); + getPS().closeConnection(); //for(int a=0;a<1000000000;a++); while(1){ - //while(1){ -// USB::getSerial().printf("sending 0's\n"); -// getPS().openConnection(); -// USB::getSerial().printf("connection open!\r\n"); -// for(int b=0;b<50;b++){ -// for(int a=0;a<sizeof(PacketStruct)-1;a++){ -// while(!getPS().outputDevice.writeable()){} -// getPS().outputDevice.putc(0); -// } -// while(!getPS().outputDevice.writeable()){} -// getPS().outputDevice.putc(0xFF); -// } -// USB::getSerial().printf("sent all data\r\n"); -// //for(int a=0;a<10000000;a++); -// getPS().closeConnection(); -// //for(int a=0;a<10000000;a++); -// } + while(1){ + USB::getSerial().printf("sending 0's\n"); + //getPS().openConnection(); + USB::getSerial().printf("connection open!\r\n"); + imageHand.run(); + USB::getSerial().printf("sent all data\r\n"); + //for(int a=0;a<10000000;a++); + //getPS().closeConnection(); + //for(int a=0;a<10000000;a++); + } // Run image handler USB::getSerial().printf("Check Image\n");
--- a/packet.h Sun Apr 20 08:04:37 2014 +0000 +++ b/packet.h Sun Apr 20 22:01:05 2014 +0000 @@ -17,6 +17,7 @@ PT_REQLOC, PT_SENDLOC, PT_WAY, + PT_GETCOMMANDS, PT_SIZE }; typedef struct PacketStruct{ @@ -77,12 +78,17 @@ void openConnection(char close_conn = 0){ __disable_irq(); - while(!getTCPConStatus){ - setTCPConStatus = 0; - wait_us(500000); + do{ + USB::getSerial().printf("trying to connect...\r\n"); + if(getTCPConStatus){ + setTCPConStatus = 0; + while(getTCPConStatus){} + wait_us(50000); + } setTCPConStatus = 1; - wait_us(500000); - } + while(setTCPConStatus==1 && !getTCPConStatus){} + }while(!getTCPConStatus); + __enable_irq(); //for(int a=0;a<10000000;a++); // char connected = 0; @@ -162,12 +168,13 @@ // for(int a=0;a<1000000;a++); } void closeConnection(){ - wait_us(100000); __disable_irq(); - while(getTCPConStatus){ + wait_us(50000); + do{ + USB::getSerial().printf("disconnecting...\r\n"); setTCPConStatus = 0; wait_us(50000); - } + }while(getTCPConStatus); } unsigned int min(unsigned int a,unsigned int b){ return a<b ? a : b; @@ -185,6 +192,7 @@ sendPacket(output); } }else{ + //openConnection(); PacketStruct output; output.type=type; output.size=0; @@ -195,6 +203,9 @@ for(int a=0;a<PACKETSIZE;a++){output.data[a]='\0';} sendPacket(output); } + if(type == PT_END){ + //closeConnection(); + } } PacketStruct* lastValid; bool found;