ptme ip core packet insertion

This commit is contained in:
Jakob Meier
2021-09-26 08:29:30 +02:00
parent 773627dc3d
commit 5b26564058
20 changed files with 252 additions and 722 deletions

View File

@ -3,7 +3,7 @@
PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF,
gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) :
SystemObject(objectId), gpioComIF(gpioComIF), uioVcInterface(uioVcInterface), papbBusyId(
SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId(
papbBusyId), papbEmptyId(papbEmptyId), vcOffset(vcOffset) {
}
@ -15,19 +15,19 @@ void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) {
vcBaseReg = ptmeBaseAddress + vcOffset;
}
ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t dataLen) {
ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) {
if(pollPapbBusySignal() == RETURN_OK) {
startPacketTransfer();
}
for(size_t idx = 0; idx < dataLen; idx++) {
for(size_t idx = 0; idx < size; idx++) {
if(pollPapbBusySignal() == RETURN_OK) {
*(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(*(data + idx));
}
else {
sif::warning << "PapbVcInterface::sendTm: Only written " << idx - 1 << " of "
<< dataLen << " data" << std::endl;
<< size << " data" << std::endl;
return RETURN_FAILED;
}
}
@ -95,7 +95,7 @@ ReturnValue_t PapbVcInterface::sendTestFrame() {
testPacket[idx] = static_cast<uint8_t>(idx & 0xFF);
}
ReturnValue_t result = sendTm(testPacket, 1105);
ReturnValue_t result = write(testPacket, 1105);
if(result != RETURN_OK) {
return result;
}

View File

@ -5,8 +5,8 @@
#include "linux/obc/VcInterfaceIF.h"
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include <linux/obc/PapbVcInterface.h>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/objectmanager/ObjectManager.h"
/**
* @brief This class handles the transmission of data to a virtual channel of the PTME IP Core
@ -14,7 +14,9 @@
*
* @author J. Meier
*/
class PapbVcInterface : VcInterfaceIF, HasReturnvaluesIF {
class PapbVcInterface: public SystemObject,
public VcInterfaceIF,
public HasReturnvaluesIF {
public:
/**
* @brief Constructor
@ -31,6 +33,10 @@ public:
gpioId_t papbEmptyId, uint32_t vcOffset);
virtual ~PapbVcInterface();
ReturnValue_t write(const uint8_t* data, size_t size) override;
void setRegisterAddress(uint32_t* ptmeBaseAddress) override;
private:
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE;

View File

@ -3,6 +3,7 @@
#include <linux/obc/Ptme.h>
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "PtmeConfig.h"
Ptme::Ptme(object_id_t objectId) :
SystemObject(objectId) {
@ -12,9 +13,8 @@ Ptme::~Ptme() {
}
ReturnValue_t Ptme::initialize() {
ReturnValue_t result = TmTcBridge::initialize();
fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR);
int fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR);
if (fd < 1) {
sif::warning << "Ptme::initialize: Invalid UIO device file" << std::endl;
return RETURN_FAILED;
@ -32,10 +32,15 @@ ReturnValue_t Ptme::initialize() {
return RETURN_FAILED;
}
return result;
VcInterfaceMapIter iter;
for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) {
iter->second->setRegisterAddress(ptmeBaseAddress);
}
return RETURN_OK;
}
ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t dataLen) {
ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) {
ReturnValue_t result = RETURN_OK;
VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId);
if (vcInterfaceMapIter == vcInterfaceMap.end()) {
@ -43,13 +48,13 @@ ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t dataLen
"channel with id " << static_cast<unsigned int>(vcId) << std::endl;
return UNKNOWN_VC_ID;
}
result = vcInterfaceMapIter->second.write(data, size);
result = vcInterfaceMapIter->second->write(data, size);
return result;
}
void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) {
if (vcId > config::MAX_VIRTUAL_CHANNEL_ID) {
if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) {
sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl;
return;
}

View File

@ -18,8 +18,13 @@
* The IP cores are implemented on the programmable logic and are accessible through the
* linux UIO driver.
*/
class Ptme : PtmeIF, SystemObject, HasReturnvaluesIF {
class Ptme : public PtmeIF,
public SystemObject,
public HasReturnvaluesIF {
public:
using VcId_t = uint8_t;
/**
* @brief Constructor
*
@ -29,7 +34,7 @@ public:
virtual ~Ptme();
ReturnValue_t initialize() override;
ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) override;
ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override;
/**
* @brief This function adds the reference to a virtual channel interface to the vcInterface
@ -73,8 +78,6 @@ private:
uint32_t* ptmeBaseAddress = nullptr;
using VcId_t = uint8_t;
using VcInterfaceMap = std::unordered_map<VcId_t, VcInterfaceIF*>;
using VcInterfaceMapIter = VcInterfaceMap::iterator;

View File

@ -20,7 +20,7 @@ namespace PtmeConfig {
static const uint32_t VC2_OFFSETT = 0x8000;
static const uint32_t VC3_OFFSETT = 0xC000;
static const std::string UIO_DEVICE_FILE = "/dev/uio0";
static const char UIO_DEVICE_FILE[] = "/dev/uio0";
};
#endif /* LINUX_OBC_PTMECONFIG_H_ */

View File

@ -22,7 +22,7 @@ public:
* @param data Pointer to buffer holding the data to write
* @param size Number of bytes to write
*/
virtual ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) = 0;
virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0;
};
#endif /* LINUX_OBC_PTMEIF_H_ */

View File

@ -1,6 +1,7 @@
#ifndef LINUX_OBC_VCINTERFACEIF_H_
#define LINUX_OBC_VCINTERFACEIF_H_
#include <stddef.h>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
/**
@ -20,7 +21,9 @@ public:
* @param data Pointer to buffer holding the data to write
* @param size Number of bytes to write
*/
virtual ReturnValue_t write(uint8_t* data, size_t size) = 0;
virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0;
virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0;
};
#endif /* LINUX_OBC_VCINTERFACEIF_H_ */