Download LTU - EX - - 05/157 -
Transcript
Guidance system Netserver program Attitude and guidance control A/D Filter TCP/IP Send Remote Computer Data acquisition card TCP/IP Listen File logger Rocket Ignition and thrust control Startup Rocket Motor Figure E.2: Framework communication flow. E.4.6 Remote command relaying We are now ready to go back to the Listen thread command interpreter. The case ID_START_AD looked like this: case ID_START_AD: MsgSendPulse(chid_filt,pulseprio,COMMAND_PULSE_CODE,ID_START_AD); MsgSendPulse(chid_send,pulseprio,COMMAND_PULSE_CODE,ID_START_AD); break; The exact same pulse is being sent to two different channels, one to chid_filt (Filter thread), and one to chid_send, (Send thread). Besides the connection identifier, each pulse has a priority, a pulse code and a value to be entered in that order when MsgSendPulse() is issued. The COMMAND pulse code is used in order to tell the particular thread that a remote command has been received (or locally issued). The command type is passed in the value field of the MsgSendPulse() function. Note that the ID List macro is reused here. Thus the ID List defined in IDList.h is used both for network communication as well as internal communication. Other pulsecodes used are defined in the file pulsecodes.h. E.4.7 Sending measurement data over the TCP/IP connection When an ID_START_AD command pulse is received by the Send thread, it starts sending measurement data to the remote client. In the current implementation it sends measurements every second, controlled by a timer. The thread uses a wrapper function to add a measurement packet to the current TCP/IP send buffer. The essential code is found below: pthread_rwlock_rdlock(&ad_data.rwl); nsend+=addAnalogData2Buffer(&ptr,ID_CHAN0,ad_data.channel[0]); nsend+=addAnalogData2Buffer(&ptr,ID_CHAN1,ad_data.channel[1]); pthread_rwlock_unlock(&ad_data.rwl); 72