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