Commit 95ba7505 authored by kpetersn's avatar kpetersn
Browse files

Added a serialPort argument to LinkamConfig. Use OpenCommsFromDevice instead...

Added a serialPort argument to LinkamConfig. Use OpenCommsFromDevice instead of OpenComms so that a linux serial port may be specified.
parent 06dcba19
......@@ -3,18 +3,20 @@
#include <iocsh.h>
#include <epicsExport.h>
#include <epicsString.h>
#include "Linkam_T96.h"
// Is this needed?
using namespace std;
Linkam::Linkam(const char *portName) : asynPortDriver(portName, MAX_CONTROLLERS,
Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(portName, MAX_CONTROLLERS,
asynInt32Mask | asynFloat64Mask | asynDrvUserMask,
asynInt32Mask | asynFloat64Mask,
ASYN_MULTIDEVICE | ASYN_CANBLOCK, 1, /* ASYN_CANBLOCK=0, ASYN_MULTIDEVICE=1, autoConnect=1 */
0, 0) /* Default priority and stack size */
{
serialPort_ = epicsStrDup(serialPort);
static const char *functionName = "Linkam";
createParam(temperatureInValueString, asynParamFloat64, &temperatureInValue_);
......@@ -38,7 +40,10 @@ Linkam::Linkam(const char *portName) : asynPortDriver(portName, MAX_CONTROLLERS,
* 1, UInt32 u32Commtype: Connection protocol (0: USB, 1: Serial)
* 3); UInt32 u32CommPort: Set to the COMM port that the controller is connected to. (e.g. COMM port 3)
*/
commStatus_ = OpenComms(true, 1, 0);
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(true, 1, 0);
commStatus_ = OpenCommsFromDevice(true, serialPort_);
// Start poller? For now just initialize the temperature
// Wrapped call to LinkamCommDll.Comms.GetValue(). Index 0 is temperature.
......@@ -51,6 +56,7 @@ Linkam::Linkam(const char *portName) : asynPortDriver(portName, MAX_CONTROLLERS,
// Disconnect
//commStatus_ = OpenComms(false, 1, 0);
//commStatus_ = OpenCommsFromDevice(false, "");
}
asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
......@@ -101,26 +107,28 @@ asynStatus Linkam::readTemperature(epicsFloat64 *value)
void Linkam::report(FILE *fp, int details)
{
asynPortDriver::report(fp, details);
fprintf(fp, "* Port: %s, commStatus=%d\n", this->portName, commStatus_);
fprintf(fp, "* Port: %s, %s, commStatus=%d\n", this->portName, serialPort_, commStatus_);
if (details >= 1)
fprintf(fp, " interesting value = ");
fprintf(fp, "\n");
}
extern "C" int LinkamConfig(const char *portName)
extern "C" int LinkamConfig(const char *portName, const char *serialPort)
{
Linkam *pLinkam = new Linkam(portName);
Linkam *pLinkam = new Linkam(portName, serialPort);
pLinkam = NULL; /* This is just to avoid compiler warnings */
return(asynSuccess);
}
static const iocshArg linkamArg0 = { "Port name", iocshArgString};
static const iocshArg * const linkamArgs[1] = {&linkamArg0};
static const iocshFuncDef linkamFuncDef = {"LinkamConfig", 1, linkamArgs};
static const iocshArg linkamArg1 = { "Serial port", iocshArgString};
static const iocshArg * const linkamArgs[2] = {&linkamArg0,
&linkamArg1};
static const iocshFuncDef linkamFuncDef = {"LinkamConfig", 2, linkamArgs};
static void linkamCallFunc(const iocshArgBuf *args)
{
LinkamConfig(args[0].sval);
LinkamConfig(args[0].sval, args[1].sval);
}
void drvLinkamRegister(void)
......
......@@ -19,7 +19,7 @@ static const char *driverName = "Linkam";
*/
class Linkam : public asynPortDriver {
public:
Linkam(const char *portName);
Linkam(const char *portName, const char *serialPort);
/* These are the methods that we override from asynPortDriver */
virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
......@@ -33,6 +33,7 @@ private:
asynStatus readTemperature(epicsFloat64 *value);
void report(FILE *fp, int details);
char* serialPort_;
int commStatus_;
float temperatureRbv_;
char* wrapperVersion_;
......
......@@ -5,4 +5,4 @@ dbLoadRecords("$(ASYN)/db/asynRecord.db", "P=kmp:,R=asyn,PORT=$(PORT),ADDR=0,OMA
## Run Linkam C# code
cd "${TOP}/bin/${ARCH}"
LinkamConfig("$(PORT)")
LinkamConfig("$(PORT)", "/dev/ttyUSB0")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment