95 uint8 const *
const aData,
106 ptr = (
uint8 *)aData;
108 for( i = 0; i < aSize; i++ )
189 payloadEnd = payloadStart;
214 if( payloadStart == payloadEnd )
259 while( prevHead != endOfFrame )
263 prevHead = ( prevHead >= (
mFifo.
size - 1 ) ) ? 0 : prevHead + 1;
336 memmove( &aData[ wrapSize ], &
mFifo.
buffer[0], aSize - wrapSize );
406 ASSERT( thePacket != NULL );
Abstract base class for the physical layer.
virtual void rx(uint8 const *const aData, uint32 const aSize)
Copy Data to FIFO.
#define MIN_PACKET_SIZE
Minimum packet size: DLE + Packet ID + Payload Size + Data + Checksum + DLE + ETX.
uint8 mFrame[MAX_PACKET_SIZE]
The packet as transmitted on the serial link (with DLE stuffing)
int numBytesInFifo()
Calculate the number of bytes in the FIFO buffer.
#define SIZE_OF_FOOTER
Size of packet footer (after payload and checksum)
GarminLinkLayer()
Construct a new GarminLinkLayer.
virtual bool tx(uint8 *aData, uint16 aSize)=0
Transmit data.
uint32 head
Index of first byte of data.
uint8 mChecksum
Twos-complement checksum of this packet.
static GarminLinkLayer * getInstance()
Get the one and only link layer object.
bool getPacketFromFifo()
Frame Packet.
uint8 buffer[FIFO_SIZE]
Data buffer.
virtual void rx(Packet *aPacket)=0
Callback when a complete packet is assembled by the LinkLayer.
#define SIZE_OF_HEADER
Size of packet header, before DLE stuffing.
fifo_type mFifo
FIFO (First-In, First-Out) buffer used to store bytes received from the client until they are parsed ...
void resetPhysicalLayer(PhysicalLayer *aPort)
Reset the physical layer.
PhysicalLayer * mPhysicalLayer
The serial port that this link layer communicates with.
void incrementHead(uint32 aIncrement)
Increment FIFO head.
static SerialPort * getInstance()
Get the one and only serial port object.
uint8 mPayload[MAX_PAYLOAD_SIZE]
The payload, before DLE stuffing.
id_type mPacketId
A complete serial packet.
Abstract base class for a packet of data.
virtual void tx(Packet *aPacket, bool aSendNow)=0
Transmit a packet.
void getDataFromFifo(uint8 *aData, uint32 aSize)
Get Data From FIFO.
uint16 mFrameSize
Number of bytes in the packet, with header, footer, and DLE stuffing.
uint32 tail
Index of last byte of data.
virtual void setLinkLayer(LinkLayer *aLinkLayer)
Change the link layer that receives bytes from this SerialPort.
TransportLayer * mTransportLayer
The transport layer that this link layer communicates with.
unsigned char uint8
8-bit unsigned integer
void setPhysicalLayer(PhysicalLayer *aPort)
Set the physical layer.
static GarminLinkLayer * sInstance
The one and only instance of this class.
uint8 mPayloadSize
Size of the payload, before DLE stuffing.
uint32 size
Number of bytes of data in the buffer.
Link Layer in the OSI model.
static void logRawData(Packet *aPacket, bool aIsTx=true)
Logs the raw data of the packet passed in to a file.
#define FIFO_SIZE
The size of the server's internal FIFO buffer for parsing raw data into packets for processing...
unsigned long int uint32
32-bit unsigned integer
static void destroyInstance()
Delete the one and only link layer object.
Physical layer implementation for a serial port.
virtual bool tx(Packet *aPacket)
Transmit a packet.