UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


projects:high_altitude_slug:software:protocol

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:high_altitude_slug:software:protocol [2006/07/03 15:29] – (old revision restored) 127.0.0.1projects:high_altitude_slug:software:protocol [2008/07/19 23:33] (current) – external edit 127.0.0.1
Line 6: Line 6:
  
 ===== Commands ===== ===== Commands =====
 +We have a 16 bit unsigned integer for commands:
  
-===== Client Library Functions ===== +==== Human messages (0 - 9) ====
-==== client_init ==== +
-The ''client_init'' function should be called before any other client related functions and connects to ''serverAddr'' (probably ''localhost'') on port ''port''. Both of these values should be #defined in ''config.h'' as SERVER and PORT respectively. The function is prototyped as: +
-  unsigned short client_init (char *serverAddr, unsigned short port); +
-in client.h+
  
-On success ''client_init'' function returns the socket file descriptor of the server that it has connected to which should be passed to all client-related functions. On failure the function returns -1 and makes a note in the client error log.+  * [0 9] CMD_MESSAGE_[0-9] char - Human messages. 0 is lowest priority, 9 is highest.
  
-==== client_recv_packet ==== +==== All processes ==== 
-The ''client_recv_packet'' function is used to read packets of data from the server. It reads a single packet of data from ''serverFD'' (the servers network file descriptor returned by ''client_init'') and then places the packet into ''packet'' which should be a pointer to a ''client_packet'' structure. It is prototyped as: +  * 10 CMD_ERROR int - Error occured 
-  int client_recv_packet (unsigned short serverFD, struct client_packet *packet); +==== GPS reader ==== 
-in client.h+  * 5000 CMD_GPS_DATA struct gps_data - GPS data
  
-The ''client_recv_packet'' function will automatically perform byte-conversions on ''packet->command'' and ''packet->len'' using the ''ntohs'' function.+==== Thermopile reader ====  
 +  * 5500 CMD_THERMOPILE_DATA struct thermopile_data Thermopile data
  
-First of all the function will read 4 bytes of data from the ''serverFD''convert them to the host byte order and then use the ''packet->len'' variable to work out the length of the data segment of the packet. Next''malloc'' is used to allocate enough memory to store the data segment of the packet and the null byte (''packet->len + 1'')before going onto reading the data segment into the newly allocated string and then setting the last byte to ''\0''.+==== Flight management (6000 - 6999) ==== 
 +  * 6000 CMD_STATUS int - Status of flight has changed, one of
 +    * 0 - Flight not started 
 +    * 1 - Ascent 
 +    * 2 - Descent 
 +    * 3 - Descent with parachute released 
 +    * 4 - Landed 
 +  * 6001 CMD_PARACHUTE bool - Parachute released if size > 0else a request to release 
 +  * 6003 CMD_CUTDOWN bool Glider has been cutdown if size 0else a request to release 
 +  * 6005 CMD_DESIRED_HEADING double - The desired heading calculated by the flight management. 
 +  * 6006 CMD_ALT_DROP_POSITION int 0 - not in altitude drop, 1-4position from north clockwise 
 +  * 6007 CMD_FINAL_WAYPOINT waypoint_t - The final waypoint, generally the launch point
  
-**Please note the the data segment of the packet (''packet->data'') is made up of memory allocated off of the heap, and so needs to be ''free()'''ed when no longer needed to prevent a memory leak!**+==== Roll control ====
  
-On success this function will return 0 while on failure this function will return -1 and will make a note in the error log about exactly what went wrong.+==== Pitch control ====
  
-==== client_send_packet ==== +==== Configuration ==== 
-The ''client_send_packet'' function should be used to send a packet of information to the server (aka the 'party line'). It sends ''packet'' to ''serverFD'' (which is the servers file descriptor) and is prototyped as: +See configuration files for descriptions and categorisation.
-  int client_send_packet (unsigned short serverFD, struct client_packet *packet); +
-in client.h+
  
-Like the ''client_recv_packet'' function the ''client_send_packet'' function will automatically perform byte-conversions on both ''packet->command'' and ''packet->len'' to convert them to the network byte order using ''htons'' function. +  * 10000 CMD_CONFIG_... 
- +to be finished
-On success the function will return 0 otherwise, on failure, will return -1 and make a note in the error log about what went  wrong. +
- +
-==== client_close ==== +
-The ''client_close'' function simply closes ''serverFD'' by calling the ''close'' function (which it is no more than a wrapper over) and is prototyped as: +
-  void client_close (unsigned short serverFD) +
-in client.h +
- +
-''client_close'' should be called when the connection to the server ('party line') is no longer needed.+
projects/high_altitude_slug/software/protocol.1151940547.txt.gz · Last modified: 2008/07/19 23:31 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki