Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/version-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Version History
###############

v1.17.0
-------

* FPGASerialPort class - opens virtual terminal to communicate with FPGA device.

v1.16.1
-------

Expand Down
18 changes: 0 additions & 18 deletions etc/ospl.service

This file was deleted.

6 changes: 3 additions & 3 deletions include/ILC/ILCBusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class ILCBusList : public Modbus::BusList {
*
* @return status description (enabled, standby,..).
*/
const char *getModeStr(uint8_t mode);
const char* getModeStr(uint8_t mode);

/**
* Return string with short text describing all code 18 status response.
Expand All @@ -204,7 +204,7 @@ class ILCBusList : public Modbus::BusList {
*
* @return vector of strings with status description
*/
virtual std::vector<const char *> getStatusString(uint16_t status);
virtual std::vector<const char*> getStatusString(uint16_t status);

/**
* Returns last know mode (state) of the @glos{ILC} at the address.
Expand All @@ -224,7 +224,7 @@ class ILCBusList : public Modbus::BusList {
*
* @return vector of strings with fault description
*/
virtual std::vector<const char *> getFaultString(uint16_t fault);
virtual std::vector<const char*> getFaultString(uint16_t fault);

/**
* Callback for reponse to ServerID request. See LTS-646 Code 17 (0x11) for
Expand Down
6 changes: 3 additions & 3 deletions include/Modbus/BusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class BusList : public std::vector<CommandRecord> {
* @endcode
*/
template <typename... dt>
void callFunction(uint8_t address, uint8_t func, uint32_t timing, const dt &...params) {
void callFunction(uint8_t address, uint8_t func, uint32_t timing, const dt&... params) {
emplace(end(), CommandRecord(Buffer(address, func, params...), timing));
}

Expand All @@ -258,7 +258,7 @@ class BusList : public std::vector<CommandRecord> {
* @return Total size of the response expected. If the passed response doesn't contain
* all data needed to calculate its length, returns -1.
*/
virtual int responseLength(const std::vector<uint8_t> &response);
virtual int responseLength(const std::vector<uint8_t>& response);

/**
* Process @glos{ILC} response. Address and function of the response are checked if
Expand All @@ -278,7 +278,7 @@ class BusList : public std::vector<CommandRecord> {
*
* @see ::parse(Parser)
*/
void parse(uint8_t *data, size_t len) { parse(std::vector<uint8_t>(data, data + len)); }
void parse(uint8_t* data, size_t len) { parse(std::vector<uint8_t>(data, data + len)); }

/**
* Add response callbacks. Both function code and error response code shall
Expand Down
10 changes: 5 additions & 5 deletions include/Modbus/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Modbus {
* @param len length of the buffer
*/
template <typename dt>
static const std::string hexDump(const dt *buf, size_t len) {
static const std::string hexDump(const dt* buf, size_t len) {
std::ostringstream os;
os << std::setfill('0') << std::hex;
for (size_t i = 0; i < len; i++) {
Expand All @@ -58,7 +58,7 @@ static const std::string hexDump(const dt *buf, size_t len) {
}

template <typename dt>
static const std::string hexDump(const std::vector<dt> &data) {
static const std::string hexDump(const std::vector<dt>& data) {
return hexDump<dt>(data.data(), data.size());
}

Expand Down Expand Up @@ -88,7 +88,7 @@ class LongResponse : public std::runtime_error {
* @param buf Buffer with data received
* @param len Buffer length
*/
LongResponse(uint8_t *buf, size_t len)
LongResponse(uint8_t* buf, size_t len)
: std::runtime_error(std::string("Too long response - received ") + hexDump(buf, len)) {}
};

Expand Down Expand Up @@ -129,7 +129,7 @@ class Parser : public std::vector<uint8_t> {
* @param buf target buffer to read the data
* @param len how many bytes shall be read
*/
void readBuffer(void *buf, size_t len) {
void readBuffer(void* buf, size_t len) {
if (_data + len > size()) {
throw std::out_of_range(fmt::format(
"Attempt to access data beyond buffer end (buffer index {}, but buffer length is {}).",
Expand Down Expand Up @@ -249,7 +249,7 @@ inline uint64_t Parser::read() {
template <>
inline float Parser::read() {
uint32_t d = read<uint32_t>();
float *db = reinterpret_cast<float *>(&d);
float* db = reinterpret_cast<float*>(&d);
return *db;
}

Expand Down
2 changes: 1 addition & 1 deletion include/PID/PID.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PID {
*/
void thaw() { _frozen = false; }

double get_offset(bool *changed);
double get_offset(bool* changed);

protected:
PIDParameters _current_parameters;
Expand Down
6 changes: 3 additions & 3 deletions include/PID/PIDParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace PID {
struct PIDParameters {
PIDParameters() { timestep = P = I = D = N = NAN; }

PIDParameters(const PIDParameters &pid) {
PIDParameters(const PIDParameters& pid) {
timestep = pid.timestep;
P = pid.P;
I = pid.I;
Expand All @@ -60,7 +60,7 @@ struct PIDParameters {
*
* @raise YAML::Exception on error
*/
virtual void load(const YAML::Node &node) {
virtual void load(const YAML::Node& node) {
timestep = node["Timestep"].as<double>(1);
P = node["P"].as<double>();
I = node["I"].as<double>();
Expand All @@ -76,7 +76,7 @@ struct PIDParameters {
*
* @raise YAML::Exception on error
*/
virtual void load(const YAML::Node &node, const PIDParameters &default_params) {
virtual void load(const YAML::Node& node, const PIDParameters& default_params) {
timestep = node["Timestep"].as<double>(default_params.timestep);
P = node["P"].as<double>(default_params.P);
I = node["I"].as<double>(default_params.I);
Expand Down
76 changes: 76 additions & 0 deletions include/Transports/PseudoSerialPort.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Serial communication through FPGA FIFOs.
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef __Transports_PseudoSerialPort__
#define __Transports_PseudoSerialPort__

#include <chrono>
#include <thread>

#include "Transport.h"

namespace Transports {

/**
* Encapsulates Transport to work as pseudo-serial port.
*/
class PseudoSerialPort : public Transport {
public:
PseudoSerialPort(std::shared_ptr<Transport> real_port, const char* device_name);

virtual ~PseudoSerialPort();

void init_pt();

void start();

void open() override;
void close() override;
void write(const unsigned char* buf, size_t len) override;
std::vector<uint8_t> read(size_t len, std::chrono::microseconds timeout,
LSST::cRIO::Thread* calling_thread = NULL) override;
void commands(Modbus::BusList& bus_list, std::chrono::microseconds timeout,
LSST::cRIO::Thread* calling_thread = NULL) override;
void flush() override;
void telemetry(uint64_t& write_bytes, uint64_t& read_bytes) override;

std::string tty_name;

protected:
void run();

private:
int _port_fd;

std::string _device_name;

int _buffer_len = 100;
std::chrono::microseconds _read_timeout;

std::shared_ptr<Transport> _real_port;

std::thread* _thread;
};

} // namespace Transports

#endif // !__Transports_PseudoSerialPort__
2 changes: 2 additions & 0 deletions include/Transports/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class CommunicationError : public std::runtime_error {
*/
class Transport {
public:
virtual ~Transport() {}

/**
* Opens transport connection.
*
Expand Down
7 changes: 6 additions & 1 deletion include/cRIO/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ struct Argument {

AClass : public cRIO::Application {
public:
AClass(const char* description) : Application(description), counter(0) {}
AClass(const char* description);
float counter;

protected:
void printUsage() override;
void processArg(int opt, char* optarg) override;
};

AClass::AClass(const char* description) : Application(description), counter(0) {
addArgument('a', "Append - increase counter.");
addArgument('h', "Print application help.");
}

void AClass::printUsage() {
std::cout << "A simple app. Accept -h for help. Pass -i to start interactive mode." << std::endl;
Application::printUsage();
Expand Down
5 changes: 5 additions & 0 deletions include/cRIO/CliApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ get_the_answer command.
*/
void printCommands();

/**
* Starts terminal logging.
*/
void _startLog();

/**
* Exits the application.
*
Expand Down
2 changes: 1 addition & 1 deletion include/cRIO/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Command : public Task {
*/
virtual void execute() = 0;

void reportException(const std::exception &ex) override { ackFailed(ex.what()); }
void reportException(const std::exception& ex) override { ackFailed(ex.what()); }

/**
* Acknowledges the command is in progress.
Expand Down
2 changes: 2 additions & 0 deletions include/cRIO/ControllerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ControllerThread final : public Thread, public Singleton<ControllerThread>

void startInterruptWatcherTask(FPGA* fpga);

void stopInterruptWatcherTask();

/* Add task into queue.
*
* @param task Task to enqueue.
Expand Down
10 changes: 5 additions & 5 deletions include/cRIO/IntelHex.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct IntelHexLine {

class LoadError : public std::runtime_error {
public:
LoadError(size_t line, uint16_t address, const std::string &arg) : std::runtime_error(arg) {
LoadError(size_t line, uint16_t address, const std::string& arg) : std::runtime_error(arg) {
_line = line;
_address = address;
}
Expand All @@ -73,8 +73,8 @@ class IntelHex {
*
* @throws LoadError on error
*/
void load(const std::string &fileName);
void load(std::istream &inputStream);
void load(const std::string& fileName);
void load(std::istream& inputStream);

/**
* Returns data to be written into ILC. Only three bytes out of every four
Expand All @@ -84,10 +84,10 @@ class IntelHex {
* @param startAddress returns memory start address
* @return vector with data
*/
std::vector<uint8_t> getData(uint16_t &startAddress);
std::vector<uint8_t> getData(uint16_t& startAddress);

private:
void _processLine(const char *line, IntelHexLine *hexLine, IntelRecordType::Types &recordType);
void _processLine(const char* line, IntelHexLine* hexLine, IntelRecordType::Types& recordType);
void _sortByAddress();

std::vector<IntelHexLine> _hexData;
Expand Down
4 changes: 2 additions & 2 deletions include/cRIO/InterruptWatcherTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ namespace cRIO {

class InterruptWatcherThread : public Thread {
public:
InterruptWatcherThread(FPGA* fpga) : _fpga(fpga) {}
InterruptWatcherThread(FPGA* fpga) : _fpga(fpga), _triggeredInterrupts(0) {}
~InterruptWatcherThread() { stop(std::chrono::seconds(2)); }

protected:
void run(std::unique_lock<std::mutex>& lock) override;

private:
FPGA* _fpga;
uint32_t _triggeredInterrupts = 0;
uint32_t _triggeredInterrupts;
};

class InterruptWatcherTask : public Task {
Expand Down
4 changes: 2 additions & 2 deletions include/cRIO/MPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MPU : public Modbus::BusList {
*/
MPU(uint8_t node_address);

int responseLength(const std::vector<uint8_t> &response) override;
int responseLength(const std::vector<uint8_t>& response) override;

void missing_response() override;

Expand Down Expand Up @@ -106,7 +106,7 @@ class MPU : public Modbus::BusList {
* @param values register values
* @param timing timeout (in microseconds)
*/
void presetHoldingRegisters(uint16_t start_register_address, const std::vector<uint16_t> &values,
void presetHoldingRegisters(uint16_t start_register_address, const std::vector<uint16_t>& values,
uint32_t timing = 100000);

/**
Expand Down
Loading
Loading