EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Query on TCP IP
From: Mark Rivers <[email protected]>
To: RITU JAIN <[email protected]>, "[email protected]" <[email protected]>
Date: Thu, 13 Feb 2014 13:31:19 +0000
Hi Ritu,

The devGpib device support is no longer the recommended best solution for this type of application, though it could probably work.

There are a couple of alternatives:

- StreamDevice  In this case you want to take one message packet and set the values of 50 EPICS records from it.  That is a little messy with StreamDevice, though again it could be done I think.

- asynPortDriver.  This is what I would recommend.  You write a driver based on the asynPortDriver C++ base class.  In your constructor you define a parameter in your driver for each of the 50 values in your packet.
#define myInteger1ParamString "MY_INTEGER1"
#define myDouble1ParamString "MY_DOUBLE1"
#define NUM_PARAMS 50

myDriver::myDriver(const char *myPort, const char *tcpPort)
   : asynPortDriver(myPort,
                    1, /* maxAddr */
                    NUM_PARAMS,
                    asynInt32Mask | asynFloat64Mask, /* Interface mask */
                    asynInt32Mask | asynFloat64Mask ,  /* Interrupt mask */
                    0, /* asynFlags.  This driver does not block and it is not multi-device, so flag is 0 */
                    1, /* Autoconnect */
                    0, /* Default priority */
                    0) /* Default stack size*/
   createParam(myInteger1ParamString, asynInt32, &myInteger1Param)
   createParam(myInteger2ParamString, asynInt32, &myInteger2Param)
   createParam(myDouble1ParamString, asynIFloat64, &myDouble1Param)
   status = pasynOctetSyncIO->connect(tcpPort, 0, &pasynUser, NULL);
..

Your driver will launch a thread that does the following:

char buffer(100);
epicsInt8 intValue;
epicsFloat64 doubleValue;

while (1) {
    status = pasynOctetSyncIO->read(pasynUser, ..., buffer, 100...)   // Read TCP packet from your device
    intValue =  *(epicsInt8 *)&buffer[0];   // Extract 8-bit integer at byte 0 in buffer
    setIntegerParam(myInteger1Param, intValue)
    doubleValue =  *(double *)&buffer[10];   // Extract double starting at byte 10 in buffer
    setDoubleParam(myDouble1Param, doubleValue);
...
    callParamCallbacks();
}

You create a database using asynInt32 and asynFloat64 device support.  Your drvInfo strings in the INP links are the strings you defined in your driver:

record(longin, "MyInteger1") {
    field(DTYP, "asynInt32")
    field(INP, "@asyn($(PORT), 0, 1)MY_INTEGER1")
    field(SCAN, "I/O Intr")
}

record(ai, "MyDouble1") {
    field(DTYP, "asynFloat64")
    field(INP, "@asyn($(PORT), 0, 1)MY_DOUBLE1")
    field(SCAN, "I/O Intr")
}

You can look at the example in asyn/testAsynPortDriver/src/testAsynPortDriver.cpp to see how to write the driver and the database.

The only difference is that in your driver the thread will be calling pasynOctetSyncIO->read() to read the values from the remote TCP device.

Mark

________________________________
From: RITU JAIN [[email protected]]
Sent: Wednesday, February 12, 2014 11:19 PM
To: [email protected]; Mark Rivers
Subject: Re: Query on TCP IP


Dear Sir/Madam
I have establish connection using TCP asyn module by using and also receiving 100bytes TCP data, it is stored in pgpibDpvt->msg.
I am using following gbib command

static struct gpibCmd gpibCmds[]={
    {@DSET_AI, GPIBCVITO, IB_Q_HIGH,0,0,10,10,tcpread,0,0,0,0,0},
};

and in tcp read funtion i am reading using
{
status=pasynOctet->read(asynOctetPvt,pasynUser,pgpibDpvt->msg,100,nchars,0)
}

along with other initialization command.



In the data there are 10 float numbers(i.e.40 bytes), 20 integer numbers (20 bytes) and remaining are Boolean (i.e 20bytes).

I have separated floats, integers and Booleans, now i want to assign this to PV. Kindly help me how to make various records/database (.db file), and how to assign segregated received value to process variable.

I am new in record set/process varible/db file, kindly give one example of each how received data will automatically linked with process variable and could able to reflect the received value in MEDM. (I am familiar with MEDM)
Regards
Ritu Sanjay Jain


On Wednesday, 12 February 2014 10:13 PM, RITU JAIN <[email protected]> wrote:
Dear Sir/Madam
I have establish connection using TCP asyn module, and also received 100bytes TCP data, it is stored in let assume msg->buf. In which 10 are the float (i.e.40 bytes), 20 are the integers (20 bytes) and remaining are Boolean (i.e 20bytes).

I have segregated floats, integers and Booleans, now i want to assign this to PV. Kindly help me how to make various records/database (.db file), and how to assign segregated received value to process variable.

I am very new in record set/process varible/db file, kindly give one example of each.

Regards
Ritu Jain




Replies:
RE: Query on TCP IP Emmanuel Mayssat
References:
Query on TCP IP RITU JAIN
Re: Query on TCP IP RITU JAIN

Navigate by Date:
Prev: CSS Archiving - non RDB PV Amien Crombie
Next: Binary record that recover its value after changed Antonio Borondo
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Query on TCP IP RITU JAIN
Next: RE: Query on TCP IP Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·