Commit ad5cddae authored by kpetersn's avatar kpetersn
Browse files

More changes that didn't actually make the support work on linux with mono.

parent dc3e73c2
......@@ -60,6 +60,13 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
return;
}
this->doneWorkingEventId = epicsEventCreate(epicsEventEmpty);
if (!this->doWorkEventId) {
printf("%s:%s epicsEventCreate failure for done working event\n",
driverName, functionName);
return;
}
this->initEventId = epicsEventCreate(epicsEventEmpty);
if (!this->initEventId) {
printf("%s:%s epicsEventCreate failure for init event\n",
......@@ -67,6 +74,11 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
return;
}
//epicsEventWait(this->initEventId);
// Must be in the directory with the DLL when this line is executed
//LoadMonoLibrary("LinkamCommsDll.dll");
/* Create the thread that calls the mono library */
status = (epicsThreadCreate("LinkamMonoTask", epicsThreadPriorityMedium,
epicsThreadGetStackSize(epicsThreadStackMedium),
......@@ -77,17 +89,14 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
return;
}
//epicsEventWait(this->initEventId);
// Must be in the directory with the DLL when this line is executed
//LoadMonoLibrary("LinkamCommsDll.dll");
//epicsThreadSleep(2.0);
// Force the device to connect now
//connect(this->pasynUserSelf);
this->lock();
connectFlag_ = 1;
this->unlock();
}
Linkam::~Linkam()
......@@ -119,6 +128,8 @@ void Linkam::LinkamMonoTask()
// Must be in the directory with the DLL when this line is executed
LoadMonoLibrary("LinkamCommsDll.dll");
printf("loaded mono library!\n");
// Call to internal library method, will return wrapper version.
wrapperVersion_ = GetWrapperVersion();
printf("Using Wrapper Version %s\n", wrapperVersion_);
......@@ -127,7 +138,7 @@ void Linkam::LinkamMonoTask()
printf("Comms Library Version %s\n", libraryVersion_);
//epicsEventSignal(this->initEventId);
epicsThreadSleep(15.0);
epicsThreadSleep(3.0);
/* Loop forever */
while (1) {
......@@ -149,35 +160,44 @@ void Linkam::LinkamMonoTask()
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(true, 1, 0);
commStatus_ = OpenCommsFromDevice(true, serialPort_);
printf("commStatus_ = %i\n", commStatus_);
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
status = pasynManager->exceptionConnect(this->pasynUserSelf);
while (!disconnectFlag_)
{
this->unlock();
printf("waiting for doWorkEvent\n");
epicsEventWait(this->doWorkEventId);
this->lock();
if (getValueFlag_)
{
printf("getting a value!\n");
switch (valueToGet_)
{
case u32Heater1TempR:
printf("getting a temperature!!\n");
*value = GetValue(u32Heater1TempR);
setDoubleParam(asynFunction_, *value);
break;
case u32Heater1LimitRW:
printf("getting a heater limit!!\n");
*value = GetValue(u32Heater1LimitRW);
setDoubleParam(asynFunction_, *value);
break;
case u32Heater1RateRW:
printf("getting a heater rate!!\n");
*value = GetValue(u32Heater1RateRW);
setDoubleParam(asynFunction_, *value);
break;
case u32Heater1PowerR:
printf("getting heater power!!\n");
*value = GetValue(u32Heater1PowerR);
setDoubleParam(asynFunction_, *value);
break;
......@@ -186,15 +206,18 @@ void Linkam::LinkamMonoTask()
getValueFlag_ = 0;
unlock();
callParamCallbacks();
lock();
}
//epicsEventSignal(this->doneWorkingEventId);
epicsEventSignal(this->doneWorkingEventId);
}
// Disconnect
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(false, 1, 0);
printf("DISCONNECTING!!\n");
commStatus_ = OpenCommsFromDevice(false, serialPort_);
status = pasynManager->exceptionDisconnect(this->pasynUserSelf);
......@@ -289,7 +312,7 @@ asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
}
// Update the temperatureInValue_ parameter
setDoubleParam(function, *value);
//setDoubleParam(function, *value);
callParamCallbacks();
......@@ -310,6 +333,12 @@ asynStatus Linkam::readTemperature(epicsFloat64 *value)
epicsEventSignal(this->doWorkEventId);
// might need to wait here to get the value
//epicsThreadSleep(0.05);
//this->lock();
//IAMHERE
//this->unlock();
epicsEventWait(this->doneWorkingEventId);
getDoubleParam(asynFunction_, value);
// There probably isn't a good reason to retain the temperature in a private variable;
// The value is already stored in the parameter library
......
......@@ -81,6 +81,7 @@ private:
//
epicsEventId connectEventId;
epicsEventId doWorkEventId;
epicsEventId doneWorkingEventId;
epicsEventId initEventId;
//
char currentPath_[FILENAME_MAX];
......
......@@ -5,7 +5,7 @@ include $(TOP)/configure/CONFIG
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
USR_CXXFLAGS=-I/usr/include/mono-2.0
USR_CXXFLAGS=-I/usr/include/mono-2.0 -mpreferred-stack-boundary=4 -mstackrealign
#==================================================
# build a support library
......
......@@ -19,10 +19,10 @@ linkam_registerRecordDeviceDriver pdbbase
< Linkam_T96.cmd
cd "${TOP}/iocBoot/${IOC}"
iocInit
#iocInit
## Start any sequence programs
#seq sncxxx,"user=kpetersnHost"
# Ugly hack to allow disconnecting for manual control via the screen
dbpf "$(PREFIX)asyn.AUCT" "noAutoConnect"
#dbpf "$(PREFIX)asyn.AUCT" "noAutoConnect"
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