Innomatix Support / InnomatixSupport
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MbedTransport.h Source File

MbedTransport.h

00001 /*******************************************************************
00002  *
00003  *  File: MbedTransport.h
00004  *
00005  *  Description: Communications transport layer API for Mbed
00006  *
00007  *  Copyright 2015 Innomatix, LLC., All Rights Reserved
00008  *
00009  *  THIS DOCUMENT AND ITS CONTENTS ARE INTELLECTUAL PROPERTY
00010  *  OF INNOMATIX, LLC.  ANY DUPLICATION IN PART OR WHOLE
00011  *  WITHOUT PRIOR WRITTEN CONSENT IS STRICTLY PROHIBITED.
00012  *
00013  *******************************************************************/
00014 #ifndef _MBEDTRANSPORT_H_ 
00015 #define _MBEDTRANSPORT_H_ 
00016 
00017 
00018 #define DO_SERIAL_NET
00019 
00020 #ifndef DO_SERIAL_NET
00021 #include "EthernetInterface.h"
00022 #endif
00023 
00024 
00025 #define ADDRESS_LENGTH 256
00026 
00027 
00028 typedef struct
00029 {
00030     char                Address[ADDRESS_LENGTH];
00031     int                 Port;
00032 #ifndef DO_SERIAL_NET
00033     UDPSocket           sendSocket;                    
00034     UDPSocket           receiveSocket;                 
00035     Endpoint            sendEndpoint;                  
00036     Endpoint            receiveEndpoint;
00037 #endif
00038    
00039 }TransportHandle_t, *TransportHandle_p;
00040 
00041 /**
00042 * Function to initialize ethernet, UDP socket sending and UDP socket receiving. 
00043 *   
00044 * @param h - TransportHandle that saves all of the socket information for future
00045                 use when we need to send/recieve information.
00046 * @retval result - lets us know if there was a success or error.
00047 ***********************************************************************************/
00048 int TransportInit( TransportHandle_p handle, const char *address, unsigned short port );
00049 
00050 
00051 
00052 /***********************************************************************************/
00053 void TransportClose( TransportHandle_p handle );
00054 
00055 
00056 /**
00057 * Test if the transport is ready to use.  Ensures that TransportInit() has been
00058 * called for the given handle.  May include other conditions based on the underlying
00059 * interface/connection.
00060 *       serial_net - includes testing that the DAP side of the connection is open
00061 *
00062 * NOTE: calls to TransportSend() and TransportReceive() when the transport reports
00063 *   not Ready() may block.
00064 *
00065 * @retval result - 0 indicates not ready or not connected.  1 indicates ready to use
00066 ***********************************************************************************/
00067 int TransportReady( TransportHandle_p handle );
00068 
00069 
00070 /**
00071 * Function for sending a buffer via UDP with the socket we set up in Init. 
00072 *   
00073 * @param len - length of the buffer we want to send to the server.
00074 * @param buff - the buffer we would like to send to the server.
00075 * @retval result - Value < 0 indicates error or no remote device connected.  Value >= 0 indicates number bytes sent
00076 ******************************************************************************************/
00077 int TransportSend( TransportHandle_p handle, unsigned short len, const unsigned char *buff, int timeout);
00078 
00079 
00080 /**
00081 * Function for receving a buffer via UDP with the socket we set up in Init. 
00082 *   
00083 * @param maxlen - the maximum length of the buffer we want to receive from the server.
00084 * @param buff - the buffer we would like to receiver from the server.
00085 * @retval result - Value < 0 indicates error or no remote device connected.  Value >= 0 indicates number bytes received
00086 ***********************************************************************************************/
00087 int TransportReceive( TransportHandle_p handle, unsigned short maxlen, unsigned char *buff, int timeout );
00088 
00089 
00090 #endif /* _MBEDTRANSPORT_H_ */