Skip to content

Commit

Permalink
Move SmartReceiver eFUSe warnings into OutputMonitor to be handled wi…
Browse files Browse the repository at this point in the history
…th other eFuses

Add sequence filename and timestamp if sequence is running to efUse warnings
  • Loading branch information
dkulp committed Apr 25, 2024
1 parent ba45c2a commit e02bc9f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Expand Up @@ -126,7 +126,8 @@
"filesystem": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"charconv": "cpp"
"charconv": "cpp",
"execution": "cpp"
},
"editor.formatOnSave": true,
"cmake.configureOnOpen": false
Expand Down
67 changes: 53 additions & 14 deletions src/OutputMonitor.cpp
Expand Up @@ -23,6 +23,7 @@
#include <unistd.h>
#include <vector>

#include "Sequence.h"
#include "Timers.h"
#include "Warnings.h"
#include "common.h"
Expand Down Expand Up @@ -177,9 +178,14 @@ class PortPinInfo {
for (int x = 0; x < 6; x++) {
if (receivers[x].enabled) {
std::string sri(1, (char)('A' + x));
v[sri]["enabled"] = receivers[x].isOn;
v[sri]["ma"] = receivers[x].current;
v[sri]["status"] = (receivers[x].isOn && !receivers[x].hasTriggered) || !receivers[x].isOn;
if (receivers[x].hasTriggered) {
v[sri]["status"] = false;
v[sri]["enabled"] = false;
} else {
v[sri]["enabled"] = receivers[x].isOn;
v[sri]["status"] = receivers[x].enabled;
}
if (receivers[x].pixelCount >= 0 && receivers[x].pixelCount < 0xFFFF) {
v[sri]["pixelCount"] = receivers[x].pixelCount;
}
Expand Down Expand Up @@ -392,7 +398,7 @@ void OutputMonitor::EnableOutputs() {
}
for (auto p : portPins) {
if (p->eFusePin && p->eFusePin->getValue() == p->eFuseOKValue) {
WarningHolder::RemoveWarning("eFUSE Triggered for " + p->name);
clearEFuseWarning(p, 0);
}
}
lock.unlock();
Expand Down Expand Up @@ -425,14 +431,16 @@ void OutputMonitor::SetOutput(const std::string& port, bool on) {
p->receivers[0].hasTriggered = false;
p->receivers[0].isOn = on;
int value = p->highToEnable ? on : !on;
WarningHolder::RemoveWarning("eFUSE Triggered for " + p->name);
clearEFuseWarning(p, 0);
p->enablePin->setValue(value);
return;
} else if (p->isSmartReceiver) {
for (int x = 0; x < 6; x++) {
if (port == std::string(p->name) + std::string(1, 'A' + x)) {
bool isOn = p->receivers[x].isOn && !p->receivers[x].hasTriggered;
if (on != isOn) {
if (p->receivers[x].hasTriggered) {
srCallback(pn, x, "ResetOutput");
} else if (on != isOn) {
srCallback(pn, x, "ToggleOutput");
}
}
Expand Down Expand Up @@ -513,8 +521,7 @@ void OutputMonitor::AddPortConfiguration(int port, const Json::Value& pinConfig,
}
if (a->receivers[0].isOn && !a->receivers[0].hasTriggered) {
// Output SHOULD be on, but the fuse triggered. That's a warning.
LogWarn(VB_CHANNELOUT, "eFUSE Triggered for " + a->name + "\n");
WarningHolder::AddWarning("eFUSE Triggered for " + a->name);
addEFuseWarning(a, 0);
a->receivers[0].hasTriggered = true;
}
}
Expand Down Expand Up @@ -557,13 +564,7 @@ void OutputMonitor::AddPortConfiguration(int port, const Json::Value& pinConfig,
pi->enablePin->setValue(pi->highToEnable ? 0 : 1);
}
if (pi->receivers[0].isOn) {
LogWarn(VB_CHANNELOUT, "eFUSE Triggered for " + pi->name + "\n");
// Output SHOULD be on, but the fuse triggered. That's a warning.
WarningHolder::AddWarning("eFUSE Triggered for " + pi->name);

std::map<std::string, std::string> keywords;
keywords["PORT"] = pi->name;
CommandManager::INSTANCE.TriggerPreset("EFUSE_TRIGGERED", keywords);
addEFuseWarning(pi, 0);
}
}
return true;
Expand Down Expand Up @@ -710,6 +711,37 @@ void OutputMonitor::GetCurrentPortStatusJson(Json::Value& result) {
}
}

void OutputMonitor::addEFuseWarning(PortPinInfo* pi, int rec) {
std::string name = pi->name;
if (pi->isSmartReceiver) {
name += std::string(1, 'A' + rec);
}
std::string warn = "eFUSE Triggered for " + name;

if (!pi->receivers[rec].warning.starts_with(warn)) {
if (sequence->IsSequenceRunning()) {
std::string seq = sequence->m_seqFilename;
int sTime = sequence->m_seqMSElapsed / 1000;
warn += " (" + seq + "/" + std::to_string(sTime / 60) + ":" + std::to_string(sTime % 60) + ")";
}

LogWarn(VB_CHANNELOUT, warn + "\n");
// Output SHOULD be on, but the fuse triggered. That's a warning.
WarningHolder::AddWarning(warn);
pi->receivers[rec].warning = warn;

std::map<std::string, std::string> keywords;
keywords["PORT"] = name;
CommandManager::INSTANCE.TriggerPreset("EFUSE_TRIGGERED", keywords);
}
}
void OutputMonitor::clearEFuseWarning(PortPinInfo* port, int rec) {
if (!port->receivers[rec].warning.empty()) {
WarningHolder::RemoveWarning(port->receivers[rec].warning);
port->receivers[rec].warning.clear();
}
}

void OutputMonitor::setSmartReceiverInfo(int port, int index, bool enabled, bool tripped, int current, int pixelCount) {
// printf(" %d %c: Current: %d PC: %d EN: %d TR: %d\n", port + 1, (char)('A' + index), current, pixelCount, enabled, tripped);
if (port < portPins.size()) {
Expand All @@ -718,6 +750,13 @@ void OutputMonitor::setSmartReceiverInfo(int port, int index, bool enabled, bool
portPins[port]->receivers[index].hasTriggered = tripped;
portPins[port]->receivers[index].pixelCount = pixelCount;
portPins[port]->receivers[index].current = current;

if (tripped) {
// printf(" %d %c: Current: %d PC: %d EN: %d TR: %d\n", port + 1, (char)('A' + index), current, pixelCount, enabled, tripped);
addEFuseWarning(portPins[port], index);
} else {
clearEFuseWarning(portPins[port], index);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/OutputMonitor.h
Expand Up @@ -73,4 +73,7 @@ class OutputMonitor : public httpserver::http_resource {
int curGroup = -1;

std::function<void(int port, int index, const std::string& cmd)> srCallback;

void addEFuseWarning(PortPinInfo* port, int rec = 0);
void clearEFuseWarning(PortPinInfo* port, int rec = 0);
};
42 changes: 17 additions & 25 deletions src/non-gpl/FalconV5Support/FalconV5Support.cpp
Expand Up @@ -105,6 +105,7 @@ FalconV5Support::FalconV5Support() {
OutputMonitor::INSTANCE.setSmartReceiverEventCallback([this](int port, int index, const std::string& cmd) {
togglePort = port;
toggleIndex = index;
command = cmd;
});
}
FalconV5Support::~FalconV5Support() {
Expand Down Expand Up @@ -345,6 +346,14 @@ bool FalconV5Support::ReceiverChain::generateNumberPackets(uint8_t* packet, uint
}
return false;
}
bool FalconV5Support::ReceiverChain::generateResetEFusePacket(uint8_t* packet, int receiver, int port) const {
Json::Value config;
config["type"] = "resetFuses";
config["receiver"] = receiver;
config["port"] = port;
return encodeFalconV5Packet(config, packet);
}

bool FalconV5Support::ReceiverChain::generateResetFusesPacket(uint8_t* packet) const {
Json::Value config;
config["type"] = "resetFuses";
Expand All @@ -366,34 +375,13 @@ void FalconV5Support::ReceiverChain::handleQueryResponse(Json::Value& json) {
int index = json["index"].asInt();
int port = json["port"].asInt();
int dial = json["dial"].asInt();

int numPorts = json["numPorts"].asInt();
if (ports[index].size() < numPorts) {
ports[index].resize(numPorts);
}
for (int x = 0; x < numPorts; x++) {
ports[index][x].current = json["ports"][x]["current"].asInt();
ports[index][x].pixelCount = json["ports"][x]["pixelCount"].asInt() == 0xFFFF ? 0 : json["pixelCount"].asInt();
ports[index][x].fuseBlown = json["ports"][x]["fuseBlown"].asBool();
ports[index][x].fuseOn = json["ports"][x]["fuseOn"].asBool();

OutputMonitor::INSTANCE.setSmartReceiverInfo(port + x % 4, x / 4,
ports[index][x].fuseOn,
ports[index][x].fuseBlown,
ports[index][x].current,
json["ports"][x]["fuseOn"].asBool(),
json["ports"][x]["fuseBlown"].asBool(),
json["ports"][x]["current"].asInt(),
json["ports"][x]["pixelCount"].asInt());

if (ports[index][x].fuseBlown) {
char idx = 'A' + index;
std::string w = "eFUSE Triggered for port " + std::to_string(port + x + 1) + idx;
if (w != ports[index][x].warning) {
ports[index][x].warning = w;
WarningHolder::AddWarning(ports[index][x].warning);
}
} else if (!ports[index][x].warning.empty()) {
WarningHolder::RemoveWarning(ports[index][x].warning);
ports[index][x].warning = "";
}
}
}

Expand Down Expand Up @@ -431,7 +419,11 @@ bool FalconV5Support::generateDynamicPacket(std::vector<std::array<uint8_t, 64>>
}
int rcP = rc->getPixelStrings().front()->m_portNumber;
if (rcP <= togglePort && (rcP + 4) > togglePort) {
rc->generateToggleEFusePacket(&packets[rc->getPixelStrings().front()->m_portNumber][0], toggleIndex, togglePort % 4);
if (command == "ToggleOutput") {
rc->generateToggleEFusePacket(&packets[rc->getPixelStrings().front()->m_portNumber][0], toggleIndex, togglePort % 4);
} else if (command == "ResetOutput") {
rc->generateResetEFusePacket(&packets[rc->getPixelStrings().front()->m_portNumber][0], toggleIndex, togglePort % 4);
}
togglePort = -1;
} else if (triggerPixelCount) {
rc->generatePixelCountPacket(&packets[rc->getPixelStrings().front()->m_portNumber][0]);
Expand Down
12 changes: 2 additions & 10 deletions src/non-gpl/FalconV5Support/FalconV5Support.h
Expand Up @@ -26,14 +26,6 @@ class FalconV5Support {
FalconV5Support();
~FalconV5Support();

class PortInfo {
public:
uint32_t current = 0;
uint32_t pixelCount = 0;
bool fuseBlown = false;
bool fuseOn = false;
std::string warning;
};
class ReceiverChain {
public:
ReceiverChain(PixelString* p1, PixelString* p2, PixelString* p3, PixelString* p4, int grp = 0, int m = 0);
Expand All @@ -42,6 +34,7 @@ class FalconV5Support {
bool generateQueryPacket(uint8_t* packet, int receiver) const;
bool generateResetFusesPacket(uint8_t* packet) const;
bool generateToggleEFusePacket(uint8_t* packet, int receiver, int port) const;
bool generateResetEFusePacket(uint8_t* packet, int receiver, int port) const;

const std::array<const PixelString*, 4>& getPixelStrings() const { return strings; };
uint32_t getReceiverCount() const { return numReceivers; }
Expand All @@ -59,8 +52,6 @@ class FalconV5Support {
uint32_t numReceivers;

uint32_t curReceiverQuery = 0;

std::array<std::vector<PortInfo>, 6> ports;
};

ReceiverChain* addReceiverChain(PixelString* p1, PixelString* p2, PixelString* p3, PixelString* p4, int group, int mux);
Expand Down Expand Up @@ -89,4 +80,5 @@ class FalconV5Support {

int togglePort = -1;
int toggleIndex = -1;
std::string command;
};
Binary file modified src/non-gpl/FalconV5Support/libFalconV5.so.zst
Binary file not shown.
10 changes: 5 additions & 5 deletions www/currentmonitor.php
Expand Up @@ -87,11 +87,11 @@ function StartMonitoring() {
} else {
rn = port["row"];
FormatSmartReceiver(port["name"], "A", port["A"], rn, port["col"]);
FormatSmartReceiver(port["name"], "B", port["B"], rn + 1, port["col"]);
FormatSmartReceiver(port["name"], "C", port["C"], rn + 2, port["col"]);
FormatSmartReceiver(port["name"], "D", port["D"], rn + 3, port["col"]);
FormatSmartReceiver(port["name"], "E", port["E"], rn + 4, port["col"]);
FormatSmartReceiver(port["name"], "F", port["F"], rn + 5, port["col"]);
FormatSmartReceiver("", "B", port["B"], rn + 1, port["col"]);
FormatSmartReceiver("", "C", port["C"], rn + 2, port["col"]);
FormatSmartReceiver("", "D", port["D"], rn + 3, port["col"]);
FormatSmartReceiver("", "E", port["E"], rn + 4, port["col"]);
FormatSmartReceiver("", "F", port["F"], rn + 5, port["col"]);
}
});
});
Expand Down

0 comments on commit e02bc9f

Please sign in to comment.