MorphGI / Mbed OS LoCoMoTE_MidLevel_7-0

Dependencies:   ros_lib_kinetic

Committer:
WD40andTape
Date:
Tue Nov 27 16:52:06 2018 +0000
Revision:
19:e5acb2183d4e
Parent:
17:bbaf3e8440ad
Child:
28:8e0c502c1a50
Input is now a velocity, not a time. Output remains as a time.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WD40andTape 7:5b6a2cefbf3b 1 // HLComms.h
WD40andTape 7:5b6a2cefbf3b 2
WD40andTape 7:5b6a2cefbf3b 3 #ifndef HLCOMMS_H
WD40andTape 7:5b6a2cefbf3b 4 #define HLCOMMS_H
WD40andTape 7:5b6a2cefbf3b 5
WD40andTape 7:5b6a2cefbf3b 6 // STANDARD IMPORTS
WD40andTape 7:5b6a2cefbf3b 7 #include <sstream> // stringstream
WD40andTape 7:5b6a2cefbf3b 8 #include <vector> // vector
WD40andTape 7:5b6a2cefbf3b 9 #include <string> // strtok
WD40andTape 7:5b6a2cefbf3b 10 // MBED IMPORTS
WD40andTape 7:5b6a2cefbf3b 11 //#include "mbed.h"
WD40andTape 7:5b6a2cefbf3b 12 #include "EthernetInterface.h"
WD40andTape 7:5b6a2cefbf3b 13 #include "TCPServer.h"
WD40andTape 7:5b6a2cefbf3b 14 #include "TCPSocket.h"
dofydoink 12:595ed862e52f 15 // CUSTOM IMPORTS
dofydoink 12:595ed862e52f 16 #include "MLSettings.h"
WD40andTape 7:5b6a2cefbf3b 17
WD40andTape 7:5b6a2cefbf3b 18 struct msg_format {
WD40andTape 7:5b6a2cefbf3b 19 double psi[3][3];
WD40andTape 19:e5acb2183d4e 20 double speed;
WD40andTape 7:5b6a2cefbf3b 21 };
WD40andTape 7:5b6a2cefbf3b 22
WD40andTape 7:5b6a2cefbf3b 23 class HLComms
WD40andTape 7:5b6a2cefbf3b 24 {
WD40andTape 7:5b6a2cefbf3b 25 public:
WD40andTape 7:5b6a2cefbf3b 26
WD40andTape 7:5b6a2cefbf3b 27 struct {
WD40andTape 7:5b6a2cefbf3b 28 EthernetInterface eth; // Indicates which NetworkInterface the socket should be created on
WD40andTape 7:5b6a2cefbf3b 29 TCPServer srv; // Provides the ability to accept incoming TCP connections
WD40andTape 7:5b6a2cefbf3b 30 TCPSocket clt_sock; // Provides the ability to send a stream of data over TCP
WD40andTape 7:5b6a2cefbf3b 31 SocketAddress clt_addr; // Represents the IP address and port pair of a unique network endpoint
WD40andTape 7:5b6a2cefbf3b 32 } interfaces;
WD40andTape 7:5b6a2cefbf3b 33
WD40andTape 7:5b6a2cefbf3b 34 HLComms(short int port);
WD40andTape 7:5b6a2cefbf3b 35 int setup_server(void);
WD40andTape 7:5b6a2cefbf3b 36 int accept_connection(void);
WD40andTape 7:5b6a2cefbf3b 37 void close_server(void);
WD40andTape 9:cd3607ba5643 38 int receive_message(void);
WD40andTape 9:cd3607ba5643 39 msg_format process_message(void);
WD40andTape 17:bbaf3e8440ad 40 int send_duration_message(double *dblTime);
WD40andTape 17:bbaf3e8440ad 41 int send_sensor_message(double positions[], double pressures[]);
WD40andTape 7:5b6a2cefbf3b 42
WD40andTape 7:5b6a2cefbf3b 43 private:
WD40andTape 7:5b6a2cefbf3b 44
WD40andTape 7:5b6a2cefbf3b 45 short int _port;
WD40andTape 7:5b6a2cefbf3b 46
dofydoink 11:7029367a1840 47 unsigned char recv_buffer[400]; //1024
dofydoink 11:7029367a1840 48 char send_buffer[400]; //65
WD40andTape 17:bbaf3e8440ad 49 Mutex recv_mutex;
WD40andTape 17:bbaf3e8440ad 50 Mutex send_mutex;
WD40andTape 17:bbaf3e8440ad 51
WD40andTape 17:bbaf3e8440ad 52 int send_message(void);
WD40andTape 7:5b6a2cefbf3b 53
WD40andTape 7:5b6a2cefbf3b 54 };
WD40andTape 7:5b6a2cefbf3b 55
WD40andTape 7:5b6a2cefbf3b 56 #endif