Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ BhcConfigFiles/
st*.cmd

RELEASE_SITE

.iocsh_history
2 changes: 2 additions & 0 deletions configure/RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# ==========================================================
ASYN_MODULE_VERSION=R4.39-1.0.2
MODBUS_MODULE_VERSION=R3.2-1.0.2
PVXS_MODULE_VERSION=R1.2.2-0.2.0

# ==========================================================
# Define module paths using pattern
Expand All @@ -53,6 +54,7 @@ MODBUS_MODULE_VERSION=R3.2-1.0.2
# ==========================================================
ASYN=$(EPICS_MODULES)/asyn/$(ASYN_MODULE_VERSION)
MODBUS=$(EPICS_MODULES)/modbus/$(MODBUS_MODULE_VERSION)
PVXS=$(EPICS_MODULES)/pvxs/$(PVXS_MODULE_VERSION)

# Motor module only required for EL7XXX support
#MOTOR=$(EPICS_MODULES)/motor/$(MOTOR_MODULE_VERSION)
Expand Down
3 changes: 2 additions & 1 deletion ek9000App/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ ek9000Support_SRCS += devEL4XXX.cpp
ek9000Support_SRCS += devEL50XX.cpp
ek9000Support_SRCS += ekUtil.cpp

ek9000Support_LIBS += $(EPICS_BASE_IOC_LIBS)
ek9000Support_LIBS += modbus
ek9000Support_LIBS += asyn
ek9000Support_LIBS += pvxs
ek9000Support_LIBS += $(EPICS_BASE_IOC_LIBS)

ifeq ($(ENABLE_MOTOR_SUPPORT),1)
ek9000Support_SRCS += devEL7XXX.cpp
Expand Down
67 changes: 66 additions & 1 deletion ek9000App/src/devEK9000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@
#include <int64outRecord.h>
#include <dbStaticLib.h>

/* pvxs includes */
#include "pvxs/server.h"
#include "pvxs/sharedpv.h"
#include "pvxs/nt.h"
#include "pvxs/iochooks.h"

/* Modbus or asyn includes */
//#include <drvModbusAsyn.h>
#include <drvAsynIPPort.h>
#include <modbusInterpose.h>

Expand Down Expand Up @@ -511,6 +516,10 @@ bool devEK9000::ComputeTerminalMapping() {
m_digital_buf = (uint16_t*)calloc(m_digital_cnt, sizeof(uint16_t));
else
m_digital_buf = NULL;

/* Expose debug PVs using pvxs */
SetupDebugPVs();

return true;
}

Expand Down Expand Up @@ -874,6 +883,62 @@ const char* devEK9000::ErrorToString(int i) {
}
}

/**
* Setup debug PVs with pvxs.
* Requires that we have pvxs and qsrv2 built into the IOC.
*/
void devEK9000::SetupDebugPVs() {
using namespace pvxs;

auto server = pvxs::ioc::server();
if (!server) {
epicsPrintf("%s: No qsrv2 server, skipping debug PVs\n", __func__);
return;
}

auto type = pvxs::TypeDef(pvxs::TypeCode::StructA, {});

/* Type for each terminal */
auto termType = TypeDef(TypeCode::Struct, {
Member(TypeCode::UInt32, "type"),
Member(TypeCode::Bool, "digital"),
Member(TypeCode::Bool, "analog"),
Member(TypeCode::UInt32, "inputSize"),
Member(TypeCode::UInt32, "outputSize"),
Member(TypeCode::UInt32, "inputStart"),
Member(TypeCode::UInt32, "outputStart"),
});

shared_array<Value> vals;
vals.resize(m_terms.size());

auto value = type.create();

int n = 0;
for (auto& t : m_terms) {
auto tval = termType.create();
tval["type"] = t->m_terminalId;
tval["digital"] = t->m_terminalFamily == TERMINAL_FAMILY_DIGITAL;
tval["analog"] = t->m_terminalFamily == TERMINAL_FAMILY_ANALOG;
tval["inputSize"] = t->m_inputSize;
tval["outputSize"] = t->m_outputSize;
tval["inputStart"] = t->m_inputStart;
tval["outputStart"] = t->m_outputStart;

vals[n++] = tval;
}

value.from(vals.freeze());

/* Create the PV */
if (m_debugPv.isOpen())
m_debugPv.close();
m_debugPv = pvxs::server::SharedPV::buildReadonly();

m_debugPv.open(value);
server.addPV("test", m_debugPv);
}

//==========================================================//
// IOCsh functions here
//==========================================================//
Expand Down
7 changes: 7 additions & 0 deletions ek9000App/src/devEK9000.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include <errlog.h>
#include <epicsMessageQueue.h>

#include "pvxs/sharedpv.h"

#include <drvModbusAsyn.h>
#include <asynPortDriver.h>

Expand Down Expand Up @@ -226,6 +228,8 @@ class devEK9000 : public drvModbusAsyn {
uint16_t m_terminals[TERMINAL_REGISTER_COUNT];
bool m_readTerminals;

pvxs::server::SharedPV m_debugPv;

public:
static devEK9000* FindDevice(const char* name);

Expand Down Expand Up @@ -359,6 +363,9 @@ class devEK9000 : public drvModbusAsyn {
bool operator==(const devEK9000& other) const {
return (strcmp(this->m_name.data(), other.m_name.data()) == 0);
}

protected:
void SetupDebugPVs();
};

class DeviceLock FINAL {
Expand Down
3 changes: 3 additions & 0 deletions ek9000TestApp/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ ek9000Test_DBD += devEK9000.dbd
ek9000Test_DBD += asyn.dbd
ek9000Test_DBD += modbusSupport.dbd
ek9000Test_DBD += drvAsynIPPort.dbd
ek9000Test_DBD += pvxsIoc.dbd

# Include dbd files from all support applications:

# Add all the support libraries needed by this IOC
ek9000Test_LIBS += ek9000Support
ek9000Test_LIBS += modbus
ek9000Test_LIBS += asyn
ek9000Test_LIBS += pvxs
ek9000Test_LIBS += pvxsIoc

# ek9000Test_registerRecordDeviceDriver.cpp derives from ek9000Test.dbd
ek9000Test_SRCS += ek9000Test_registerRecordDeviceDriver.cpp
Expand Down
4 changes: 2 additions & 2 deletions iocBoot/iocEK9KTest/gen-cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

terms = []
if use_modbus and (args.terminals is None or len(args.terminals) == 0):
client = ModbusTcpClient(args.ip, args.port)
client = ModbusTcpClient(args.ip, port=args.port)
if not client.connect():
print('Connection to coupler failed, use --terminals instead')
sys.exit(1)
resp = client.read_holding_registers(0x6001, 125)
resp = client.read_holding_registers(0x6001, count=125)
for r in resp.registers:
if r == 0:
break
Expand Down
Loading