Hi Bertrand,
You can certainly do this.
You will be writing an "asyn port driver". You need to decide what
asyn
interfaces your driver will implement (asynOctet, asynInt32,
asynUInt32Digital, asynFloat64, etc.). Unless the device is very
unusual you won't need to write any EPICS device support, you can use
the standard asyn EPICS device support, which will then talk to your
driver.
You then write your driver to implement the interfaces that you have
chosen to support. For example, if you implement asynFloat64, then
your
asynFloat64Read function will call the C function that the vendor
provided to read some double parameter from the device. You will
probably want to implement asynDrvUser interface to handle the need to
handle multiple parameters for each asyn interface. Your template
file
might look like:
# ai records to read voltage and current
record(ai, "$(P)Current") {
field(DTYP,"asynFloat64")
field(INP,"@asynMask($(PORT) $(ADDR))VOLTAGE")
field(LINR,"LINEAR")
field(EGUL,"$(EGUL)")
field(EGUF,"$(EGUF)")
field(HOPR,"$(EGUF)")
field(LOPR,"$(EGUL)")
field(PREC,"$(PREC)")
}
record(ai, "$(P)Current") {
field(DTYP,"asynFloat64")
field(INP,"@asynMask($(PORT) $(ADDR))CURRENT")
field(LINR,"LINEAR")
field(EGUL,"$(EGUL)")
field(EGUF,"$(EGUF)")
field(HOPR,"$(EGUF)")
field(LOPR,"$(EGUL)")
field(PREC,"$(PREC)")
}
Here are 2 drivers you can look at for examples:
1) The Modbus driver
http://cars.uchicago.edu/software/epics/modbus.html
2) The Canberra AIM MCA driver (source file
mcaApp/CanberraSrc/drvMcaAIMAsyn.c)
http://cars.uchicago.edu/software/epics/mca.html
Mark