Commit 24e8ed57 authored by kpetersn's avatar kpetersn
Browse files

Modifications (many hard-coded) to work on Windows. Can connect to the...

Modifications (many hard-coded) to work on Windows.  Can connect to the controller, but not read anything via USB.  Can't connect to the controller via serial.  May be a problem with the serial card.
parent d2fa461b
#include <stdio.h>
#include "dllImports.h"
//#ifdef WINDOWS
#include "dllHeader.h"
//#else
// #include "dllImports.h"
//#endif
#include <iocsh.h>
#include <epicsExport.h>
#include <epicsString.h>
......@@ -28,9 +31,9 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
createParam(heaterPowerInValueString, asynParamFloat64, &heaterPowerInValue_);
createParam(heatingOutValueString, asynParamInt32, &heatingOutValue_);
// Must be in the directory with the DLL when this line is executed
LoadMonoLibrary("LinkamCommsDll.dll");
// Must be in the directory with the DLL when this line is executed
//LoadMonoLibrary("LinkamCommsDll.dll");
// Call to internal library method, will return wrapper version.
wrapperVersion_ = GetWrapperVersion();
printf("Using Wrapper Version %s\n", wrapperVersion_);
......@@ -71,10 +74,12 @@ asynStatus Linkam::connect(asynUser *pasynUser)
* 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)
*/
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(true, 1, 0);
this->lock();
commStatus_ = OpenCommsFromDevice(true, serialPort_);
// OpenComms only works for Windows-style numbering of COM ports
commStatus_ = OpenComms(true, 1, 1);
// USB on windows
//commStatus_ = OpenComms(true, 0, 6);
//commStatus_ = OpenCommsFromDevice(true, serialPort_);
this->unlock();
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
......@@ -97,10 +102,12 @@ asynStatus Linkam::disconnect(asynUser *pasynUser)
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: Disconnecting...\n", driverName, functionName);
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(false, 1, 0);
this->lock();
commStatus_ = OpenCommsFromDevice(false, serialPort_);
//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, 6);
this->unlock();
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
......
......@@ -5,12 +5,13 @@ 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
#USR_CXXFLAGS=-clr:safe
#==================================================
# build a support library
LIBRARY_IOC_Linux += Linkam
LIBRARY_IOC += Linkam
# xxxRecord.h will be created from xxxRecord.dbd
#DBDINC += xxxRecord
......@@ -18,8 +19,11 @@ LIBRARY_IOC_Linux += Linkam
DBD += LinkamSupport.dbd
# specify all source files to be compiled and added to the library
Linkam_SRCS_Linux += Linkam_T96.cpp
Linkam_SRCS += Linkam_T96.cpp
Linkam_LIBS_Linux += Wrapper
ifeq (win, $(findstring win, $(T_A)))
Linkam_LIBS += CommsWrapper
endif
Linkam_Libs += asyn
Linkam_LIBS += $(EPICS_BASE_IOC_LIBS)
......
......@@ -7,6 +7,7 @@ include $(TOP)/configure/CONFIG
# Note, the following files were manually copied from the _____ directory.
INC += dllExports.h
INC += dllImports.h
INC += dllHeader.h
ifeq (linux-x86_64, $(findstring linux-x86_64, $(T_A)))
LIB_INSTALLS += ../os/linux-x86_64/libWrapper.a
......@@ -15,6 +16,22 @@ BIN_INSTALLS += ../os/linux-x86_64/libWrapper.so
BIN_INSTALLS += ../os/linux-x86_64/LinkamCommsDll.dll
endif
ifeq (win32-x86, $(findstring win32-x86, $(T_A)))
LIB_INSTALLS += ../os/win32-x86/CommsWrapper.lib
LIB_INSTALLS += ../os/win32-x86/CommsWrapper.dll
BIN_INSTALLS += ../os/win32-x86/CommsWrapper.dll
BIN_INSTALLS += ../os/win32-x86/LinkamCommsLibrary.dll
BIN_INSTALLS += ../os/win32-x86/Multimedia.dll
endif
ifeq (windows-x64, $(findstring windows-x64, $(T_A)))
LIB_INSTALLS += ../os/windows-x64/CommsWrapper.lib
LIB_INSTALLS += ../os/windows-x64/CommsWrapper.dll
BIN_INSTALLS += ../os/windows-x64/CommsWrapper.dll
BIN_INSTALLS += ../os/windows-x64/LinkamCommsLibrary.dll
BIN_INSTALLS += ../os/windows-x64/Multimedia.dll
endif
#=============================
include $(TOP)/configure/RULES
......
//Built on 11/04/2018 at 8:26:23.75 by UjasSidapara@LINKAM.LOCAL on SN1651-B
// CommsWrapper.dll SHA:E23D139EA70508CD11041786C3751D213558DCA4A2FAFFC606B4B16438FEA539
//-----------------------------------------------------------------------
// <copyright file="dllHeader.h" company="Linkam Scientific Ltd">
// Copyright (c) Linkam Scientific Ltd. All rights reserved.
// </copyright>
// <date>17-Jan-2018</date>
// <author>US (support@linkam.co.uk)</author>
//-<version>1.1.1</version>
//-----------------------------------------------------------------------
/// This file contains the dllimports/ dllexports for the wrapper.
// Dependencies:
// - C runtime Library v120
// -.net framework version 4.0 or newer
// - LinkamCommsLibrary.dll (managed)
#pragma once
#ifndef dllHeader_h
#define dllHeader_h
// if DLLEXPORTS is defined, define as dllexports,
// otherwise declare dllimport prototypes.
#ifdef DLLEXPORTS
#define DLLAPI __declspec(dllexport)
#else
#define DLLAPI __declspec(dllimport)
#endif
#define DLLCALL __cdecl // Calling convention is __cdecl
#endif
// callbacks:
// typedef return_type ( calling convention *func_pointer) (other parameters)
typedef void(__stdcall *eventCallback)(void); // stdcall used for WINAPI compatibility.
typedef void(__stdcall *eventNewValueCallback)(unsigned long long); //UInt64
extern "C" // No name mangling
{
// Open or close connection to controller
// (arg1: true=Connect, false=Disconnect arg2: 0=USB, 1=RS232, arg3: Comm port number)
DLLAPI unsigned int DLLCALL OpenComms(bool, unsigned int, unsigned int); // wraps Comms.OpenComms()
DLLAPI unsigned int DLLCALL OpenCommsFromDevice(bool bConnect, char* strSerialDevice);
// Methods in alphabetical order
DLLAPI bool DLLCALL ApplySampleCals(bool); // wraps Comms.ApplySampleCals()
// Toggle between uncalibrated and sample calibrated temperatures. Refer to example in html docs.
DLLAPI bool DLLCALL CalibrateTstDistance(void);
DLLAPI bool DLLCALL CssApplyValues(void);
DLLAPI unsigned char DLLCALL CssCheckValues(void);
DLLAPI bool DLLCALL CssGotoReference(void);
DLLAPI bool DLLCALL CssSensorCal(unsigned int);
DLLAPI bool DLLCALL CssStartJogGap(bool);
DLLAPI bool DLLCALL CssStartJogRot(bool);
DLLAPI int DLLCALL GetCommsPeriod();
DLLAPI unsigned long long DLLCALL GetControllerConfig(void); // Controller configuration: i.e. boards connected
DLLAPI unsigned int DLLCALL GetControllerError(void); // Controller error status
DLLAPI char* DLLCALL GetControllerName(void);
DLLAPI char* DLLCALL GetControllerSerial(void);
DLLAPI char* DLLCALL GetDllVersion(void); // Version number of ManagedDLL
DLLAPI char* DLLCALL GetWrapperVersion(void); // Version number of Wrapper
DLLAPI float DLLCALL GetMaxValue(unsigned int);
DLLAPI float DLLCALL GetMinValue(unsigned int);
DLLAPI float DLLCALL GetResolution(unsigned int);
DLLAPI unsigned long long DLLCALL GetStageConfig(void); // Unsigned 64-Bit Integer
DLLAPI char* DLLCALL GetStageName(void);
DLLAPI char* DLLCALL GetStageSerial(void);
DLLAPI unsigned long long DLLCALL GetStatus(void); // Unsigned 64-Bit Integer
DLLAPI float DLLCALL GetValue(unsigned int);
DLLAPI bool DLLCALL SaveSampleCals(void);
DLLAPI bool DLLCALL SetCommsPeriod(int);
DLLAPI bool DLLCALL SetLnpMode(bool);
DLLAPI bool DLLCALL SetLnpSpeed(unsigned int);
//DLLAPI bool DLLCALL SetSimulationMode(unsigned int); Deprecated as of v1.0.7/ SDK 2.3.4.1
DLLAPI bool DLLCALL SetValue(unsigned int, float);
DLLAPI bool DLLCALL StartHeating(bool);
DLLAPI bool DLLCALL StartMotors(bool, unsigned int);
DLLAPI bool DLLCALL StartVacuum(bool);
DLLAPI bool DLLCALL StartHumidity(bool);
DLLAPI bool DLLCALL StartHumidityDesiccantConditioning(bool);
DLLAPI bool DLLCALL SetTstMode(bool);
DLLAPI bool DLLCALL TstZeroForce(void);
DLLAPI bool DLLCALL TstZeroPosition(void);
// Comms Events
/*********************************************/
/* Event and callback methods */
/* See "helloLinkam" example in apiDocs */
/*********************************************/
// Start callbacks
DLLAPI void DLLCALL StartEvents();
// Stop callbacks
DLLAPI void DLLCALL StopEvents();
// Set or Register callbacks. See typedefs above for declaration of *eventCallback and *eventNewValueCallback.
DLLAPI void DLLCALL SetControllerConnectedCallback(eventCallback);
DLLAPI void DLLCALL SetNewValueCallback(eventNewValueCallback);
DLLAPI void DLLCALL SetControllerDisconnectedCallback(eventCallback);
}
......@@ -24,10 +24,10 @@ TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
# If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
ASYN=/home/KPETERSN/Current/9idc_Linkam/support/asyn
ASYN=D:/epics/linkamDevel/support/asyn
# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/APSshare/epics/base-3.14.12.5
EPICS_BASE=D:/epics/base-3.15.5
# Set RULES here if you want to take build rules from somewhere
# other than EPICS_BASE:
......
......@@ -25,11 +25,12 @@ TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
#
#LINKAM=D:/epics/linkamDevel/support/Linkam
LINKAM=$(TOP)/../..
-include $(LINKAM)/configure/RELEASE
# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/APSshare/epics/base-3.14.12.5
#!EPICS_BASE=
# Set RULES here if you want to take build rules from somewhere
# other than EPICS_BASE:
......
......@@ -5,4 +5,7 @@ dbLoadRecords("$(ASYN)/db/asynRecord.db", "P=$(PREFIX),R=asyn,PORT=$(PORT),ADDR=
## Run Linkam C# code
cd "${TOP}/bin/${ARCH}"
LinkamConfig("$(PORT)", "/dev/ttyUSB0")
# Linux
#!LinkamConfig("$(PORT)", "/dev/ttyUSB0")
# Windows
LinkamConfig("$(PORT)", "0")
TOP = ../..
include $(TOP)/configure/CONFIG
#!ARCH = linux-x86_64
ARCH = linux-x86_64-debug
#!ARCH = linux-x86_64-debug
ARCH = windows-x64-static
TARGETS = envPaths
include $(TOP)/configure/RULES.ioc
@echo off
set EPICS_HOST_ARCH=windows-x64-static
..\..\bin\%EPICS_HOST_ARCH%\linkam.exe st.cmd
pause
......@@ -8,13 +8,20 @@ include $(TOP)/configure/CONFIG
#=============================
# Build the IOC application
PROD_IOC_Linux = linkam
PROD_IOC = linkam
# linkam.dbd will be created and installed
DBD += linkam.dbd
#
ifeq (linux-x86_64, $(findstring linux-x86_64, $(T_A)))
BIN_INSTALLS += ${LINKAM}/bin/${EPICS_HOST_ARCH}/LinkamCommsDll.dll
BIN_INSTALLS += ${LINKAM}/bin/${EPICS_HOST_ARCH}/libWrapper.so
endif
ifeq (win, $(findstring win, $(T_A)))
BIN_INSTALLS += ${LINKAM}/bin/${EPICS_HOST_ARCH}/CommsWrapper.dll
BIN_INSTALLS += ${LINKAM}/bin/${EPICS_HOST_ARCH}/LinkamCommsLibrary.dll
BIN_INSTALLS += ${LINKAM}/bin/${EPICS_HOST_ARCH}/Multimedia.dll
endif
# linkam.dbd will be made up from these files:
linkam_DBD += base.dbd
......@@ -25,10 +32,13 @@ linkam_DBD += LinkamSupport.dbd
# Add all the support libraries needed by this IOC
PROD_SYS_LIBS_Linux += mono-2.0
linkam_LIBS_Linux += Linkam
linkam_LIBS += Linkam
# The following line isn't necessary, but it makes the depenency explicit
linkam_LIBS_Linux += Wrapper
linkam_LIBS_Linux += asyn
ifeq (win, $(findstring win, $(T_A)))
linkam_LIBS += CommsWrapper
endif
linkam_LIBS += asyn
# linkam_registerRecordDeviceDriver.cpp derives from linkam.dbd
linkam_SRCS += linkam_registerRecordDeviceDriver.cpp
......
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