Commit e5b0f3ab authored by kpetersn's avatar kpetersn
Browse files

Allow commType and commPort to be specified in LinkamConfig call.

parent 3c171fcb
......@@ -14,15 +14,18 @@
// Is this needed?
using namespace std;
Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(portName, MAX_CONTROLLERS,
Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt32 commPort) : 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";
// Add validation in the future
commType_ = commType;
commPort_ = commPort;
createParam(temperatureInValueString, asynParamFloat64, &temperatureInValue_);
createParam(rampLimitOutValueString, asynParamFloat64, &rampLimitOutValue_);
createParam(rampLimitInValueString, asynParamFloat64, &rampLimitInValue_);
......@@ -76,10 +79,14 @@ asynStatus Linkam::connect(asynUser *pasynUser)
*/
this->lock();
// OpenComms only works for Windows-style numbering of COM ports
commStatus_ = OpenComms(true, 1, 1);
// USB on windows
//commStatus_ = OpenComms(true, 1, 1);
// USB on windows
//commStatus_ = OpenComms(true, 0, 6);
// A different call would be needed for Linux
//commStatus_ = OpenCommsFromDevice(true, serialPort_);
//
commStatus_ = OpenComms(true, commType_, commPort_);
this->unlock();
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
......@@ -105,9 +112,12 @@ asynStatus Linkam::disconnect(asynUser *pasynUser)
this->lock();
//commStatus_ = OpenCommsFromDevice(false, serialPort_);
// OpenComms only works for Windows-style numbering of COM ports
commStatus_ = OpenComms(false, 1, 1);
// USB on Windows
//commStatus_ = OpenComms(false, 1, 1);
// USB on Windows
//commStatus_ = OpenComms(false, 1, 6);
//
commStatus_ = OpenComms(false, commType_, commPort_);
this->unlock();
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
......@@ -366,28 +376,30 @@ asynStatus Linkam::setHeating(epicsInt32 value)
void Linkam::report(FILE *fp, int details)
{
asynPortDriver::report(fp, details);
fprintf(fp, "* Port: %s, %s, commStatus=%d\n", this->portName, serialPort_, commStatus_);
fprintf(fp, "* Port: %s, commType=%d, commPort=%d, commStatus=%d\n", this->portName, commType_, commPort_, commStatus_);
if (details >= 1)
fprintf(fp, " interesting value = ");
fprintf(fp, "\n");
}
extern "C" int LinkamConfig(const char *portName, const char *serialPort)
extern "C" int LinkamConfig(const char *portName, const epicsUInt32 commType, const epicsUInt32 commPort)
{
Linkam *pLinkam = new Linkam(portName, serialPort);
Linkam *pLinkam = new Linkam(portName, commType, commPort);
pLinkam = NULL; /* This is just to avoid compiler warnings */
return(asynSuccess);
}
static const iocshArg linkamArg0 = { "Port name", iocshArgString};
static const iocshArg linkamArg1 = { "Serial port", iocshArgString};
static const iocshArg * const linkamArgs[2] = {&linkamArg0,
&linkamArg1};
static const iocshFuncDef linkamFuncDef = {"LinkamConfig", 2, linkamArgs};
static const iocshArg linkamArg1 = { "Comm Type", iocshArgInt};
static const iocshArg linkamArg2 = { "Comm port", iocshArgInt};
static const iocshArg * const linkamArgs[3] = {&linkamArg0,
&linkamArg1,
&linkamArg2};
static const iocshFuncDef linkamFuncDef = {"LinkamConfig", 3, linkamArgs};
static void linkamCallFunc(const iocshArgBuf *args)
{
LinkamConfig(args[0].sval, args[1].sval);
LinkamConfig(args[0].sval, args[1].ival, args[2].ival);
}
void drvLinkamRegister(void)
......
......@@ -32,7 +32,7 @@ static const char *driverName = "Linkam";
*/
class Linkam : public asynPortDriver {
public:
Linkam(const char *portName, const char *serialPort);
Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt32 commPort);
/* These are the methods that we override from asynPortDriver */
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
......@@ -63,7 +63,8 @@ private:
asynStatus setHeating(epicsInt32 value);
void report(FILE *fp, int details);
char* serialPort_;
epicsUInt32 commType_;
epicsUInt32 commPort_;
int commStatus_;
float temperatureRbv_;
char* wrapperVersion_;
......
......@@ -5,7 +5,11 @@ dbLoadRecords("$(TOP)/db/asynRecord.db", "P=$(PREFIX),R=asyn,PORT=$(PORT),ADDR=0
## Run Linkam C# code
cd "${TOP}/bin/${ARCH}"
# Linux
#!LinkamConfig("$(PORT)", "/dev/ttyUSB0")
# Windows
LinkamConfig("$(PORT)", "0")
# LinkamConfig(
# portName Desired asyn port name (created by driver)
# commType 0 = USB, 1 = RS232
# commPort 0 = COM0, 1 = COM1, ...
# RS232, COM1
LinkamConfig("$(PORT)", 1, 1)
# USB, device #6
#!LinkamConfig("$(PORT)", 0, 6)
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