105 lines
3.7 KiB
C++
105 lines
3.7 KiB
C++
/*
|
|
* Title: ArduinoComIF.h
|
|
* Author: Marco Modè
|
|
* Last version: 24/09/2021
|
|
* Project: ESBO-DS
|
|
*
|
|
* @ brief: Used to initialize the communication Interface (USB connector, serial port) and
|
|
* to perform the 4 periodical function described in the DeviceCommunicationIF
|
|
* (child of DeviceCommunicationIF).
|
|
* In this case sendMessage, getSendSuccess and requestReceiveMessage are
|
|
* just returning RETURN_OK.
|
|
* @ details: The ArduinoComIF is instantiated in the generic factory.
|
|
* @ ingroup: mission/DeviceHandler
|
|
*-------------------------------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
|
|
#ifndef MISSION_DEVICEHANDLER_ARDUINOCOMIF_H_
|
|
#define MISSION_DEVICEHANDLER_ARDUINOCOMIF_H_
|
|
|
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
|
#include <fsfw/ipc/MessageQueueIF.h>
|
|
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
|
#include <fsfw/serialize/SerializeAdapter.h>
|
|
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
|
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
|
#include <vector>
|
|
#include <iostream>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <algorithm>
|
|
// Linux headers
|
|
#include <fcntl.h> // Contains file controls like O_RDWR
|
|
#include <errno.h> // Error integer and strerror() function
|
|
#include <termios.h> // Contains POSIX terminal control definitions
|
|
#include <unistd.h> // write(), read(), close()
|
|
|
|
class ArduinoComIF: public DeviceCommunicationIF, public SystemObject {
|
|
public:
|
|
|
|
ArduinoComIF(object_id_t objectId);
|
|
virtual ~ArduinoComIF();
|
|
|
|
// DeviceCommunicationIF inherited functions.
|
|
ReturnValue_t initializeInterface(CookieIF *cookie) override;
|
|
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData,
|
|
size_t sendLen) override;
|
|
ReturnValue_t getSendSuccess(CookieIF *cookie) override;
|
|
ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen)
|
|
override;
|
|
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
|
size_t *size) override;
|
|
|
|
protected:
|
|
|
|
/* The buffer array to store the data read are initialized.
|
|
* The whole data packet to be read is 2580 bytes, the limit for one reading (VMAX) is 255 bytes.
|
|
* In order to avoid problems during the acquisition of data in the framework, the buffer is set to
|
|
* be 3 times the needed dimension: 7740 bytes.
|
|
* Exploiting then some control loop, the beginning of a full and complete buffer is identified.
|
|
* Since the acquisition limit for one reading is of 255 bytes, as mentioned above,
|
|
* the reading is divided in 31 separate stages which employ 31 different buffer array.
|
|
* At the end these 31 arrays are concatenated in the main buffer array read_buf.
|
|
*/
|
|
uint8_t read_buf[7740]; // 7740 bytes from SPC serial output
|
|
// Intermediate buffers (limit for one single read call is 255 bytes)
|
|
uint8_t read_buf1[255];
|
|
uint8_t read_buf2[255];
|
|
uint8_t read_buf3[255];
|
|
uint8_t read_buf4[255];
|
|
uint8_t read_buf5[255];
|
|
uint8_t read_buf6[255];
|
|
uint8_t read_buf7[255];
|
|
uint8_t read_buf8[255];
|
|
uint8_t read_buf9[255];
|
|
uint8_t read_buf10[255];
|
|
uint8_t read_buf11[255];
|
|
uint8_t read_buf12[255];
|
|
uint8_t read_buf13[255];
|
|
uint8_t read_buf14[255];
|
|
uint8_t read_buf15[255];
|
|
uint8_t read_buf16[255];
|
|
uint8_t read_buf17[255];
|
|
uint8_t read_buf18[255];
|
|
uint8_t read_buf19[255];
|
|
uint8_t read_buf20[255];
|
|
uint8_t read_buf21[255];
|
|
uint8_t read_buf22[255];
|
|
uint8_t read_buf23[255];
|
|
uint8_t read_buf24[255];
|
|
uint8_t read_buf25[255];
|
|
uint8_t read_buf26[255];
|
|
uint8_t read_buf27[255];
|
|
uint8_t read_buf28[255];
|
|
uint8_t read_buf29[255];
|
|
uint8_t read_buf30[255];
|
|
uint8_t read_buf31[90];
|
|
|
|
};
|
|
|
|
#endif /* MISSION_DEVICEHANDLER_ARDUINOCOMIF_H_ */
|