epics-motor / motorSmarAct

EPICS motor drivers for SmarAct controllers
3 stars 13 forks source link

Added MCS2 controller support. #1

Closed djvine closed 5 years ago

djvine commented 5 years ago

In this branch I added the support for the MCS2 controller.

I'm having trouble integrating the MCS and MCS2 code into a single library. The command "createMCS2Controller" in the st.cmd isn't found but I can't locate where I have a problem.

keenanlang commented 5 years ago

MCS2MotorRegister needs to be inside the extern "C" as well, otherwise the function gets name-mangled according to c++ convention and the c code can't find it.

djvine commented 5 years ago

I redefined: static void MCS2MotorRegister to extern "C" void MCS2MotorRegister but the MCS2CreateController is still not found.

keenanlang commented 5 years ago

Looks like you're also not including the dbd file that registers the function into the IOC's dbd file. iocs/smarActIOC/smarActApp/src/Makefile should have the line

smarAct_DBD += devSmarActMCS2.dbd

djvine commented 5 years ago

I appreciate these suggestions but that didn't work either.

I pushed the updated code on branch mcs2.

MarkRivers commented 5 years ago

I think you have not put enough of the code inside extern "C". Please look at the Newport driver for an example:

https://github.com/epics-motor/motorNewport/blob/master/newportApp/src/XPSController.cpp

djvine commented 5 years ago

@MarkRivers thanks.

The problem I think was that I had two dbd files with registrars and only one was included in the IOC Makefile.

Thanks for the help, it finds the function now.

kmpeters commented 5 years ago

I get build errors:

../smarActMCS2MotorDriver.cpp: In member function ‘virtual asynStatus MCS2Axis::poll(bool*)’:
../smarActMCS2MotorDriver.cpp:432:29: error: ‘stol’ is not a member of ‘std’
   encoderPosition = (double)std::stol(pC_->inString_);
                             ^
../smarActMCS2MotorDriver.cpp:440:28: error: ‘stol’ is not a member of ‘std’
   theoryPosition = (double)std::stol(pC_->inString_);
                            ^
make[3]: *** [smarActMCS2MotorDriver.o] Error 1
make[3]: Leaving directory `/net/s100dserv/xorApps/epics/motor-devel/testing/motorSmarAct/smarActApp/src/O.linux-x86_64'
make[2]: *** [install.linux-x86_64] Error 2
make[2]: Leaving directory `/net/s100dserv/xorApps/epics/motor-devel/testing/motorSmarAct/smarActApp/src'
make[1]: *** [src.install] Error 2
make[1]: Leaving directory `/net/s100dserv/xorApps/epics/motor-devel/testing/motorSmarAct/smarActApp'
make: *** [smarActApp.install] Error 2
[hobbes /net/s100dserv/xorApps/epics/motor-devel/testing/motorSmarAct]$ 

Which I can resolve by using strtod:

diff --git a/smarActApp/src/smarActMCS2MotorDriver.cpp b/smarActApp/src/smarActMCS2MotorDriver.cpp
index 80ca12e..91b2983 100644
--- a/smarActApp/src/smarActMCS2MotorDriver.cpp
+++ b/smarActApp/src/smarActMCS2MotorDriver.cpp
@@ -429,7 +429,8 @@ asynStatus MCS2Axis::poll(bool *moving)
   sprintf(pC_->outString_, ":CHAN%d:POS?", channel_);
   comStatus = pC_->writeReadController();
   if (comStatus) goto skip;
-  encoderPosition = (double)std::stol(pC_->inString_);
+  //encoderPosition = (double)std::stol(pC_->inString_);
+  encoderPosition = (double)strtod(pC_->inString_, NULL);
   encoderPosition /= PULSES_PER_STEP;
   setDoubleParam(pC_->motorEncoderPosition_, encoderPosition);

@@ -437,7 +438,8 @@ asynStatus MCS2Axis::poll(bool *moving)
   sprintf(pC_->outString_, ":CHAN%d:POS:TARG?", channel_);
   comStatus = pC_->writeReadController();
   if (comStatus) goto skip;
-  theoryPosition = (double)std::stol(pC_->inString_);
+  //theoryPosition = (double)std::stol(pC_->inString_);
+  theoryPosition = (double)strtod(pC_->inString_, NULL);
   theoryPosition /= PULSES_PER_STEP;
   setDoubleParam(pC_->motorPosition_, theoryPosition);

Has anyone else built the mcs2 branch without modification?

djvine commented 5 years ago

The std::stol built on my debian stretch with gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1).

I have updated with Kevin's revision.

Don't merge this until I can test it.

kmpeters commented 5 years ago

FYI, I'm using the versions of gcc and g++ that come with RHEL7:

[hostname ~]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[hostname ~]$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
MarkRivers commented 5 years ago

We need to maintain compatibility with such older versions of compilers, including gcc 4.3 on vxWorks and Visual Studio 2015 on Windows.

djvine commented 5 years ago

I tested this morning with MCS2 controller and everything seems to be working ok.

It can be merged with master branch if nobody sees a problem.