Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI VISA on Windows 2000 PC and Port Mapper Service

I have a question about NI VISA and port mapping service on the Windows 2000 PC that is calling networking instruments that in turn requires to open an Interrupt Channel on the VISA caller Windows PC.
 
Is NI VISA under Windows 2000 PC supporting port mapper service?
I have Ni VISA COM version 4.0.0.49512.
 
If is supporting the port mapper service on Windows 2000 how may I start this servcice if is not already started?
 
 
Thanks
 
sorinvalea
0 Kudos
Message 1 of 8
(4,823 Views)
If you are talking about VISA's VXI-11 (emulation?) server, such as redirecting incoming VXI-11/RPC calls from other PC to local GPIB bus, it must have port mapper for DEVICE_CORE channel because VXI-11 and SUN ONC RPC specs require it.  (I am not sure if NI-VISA comes with this feature, though Agilent IO Libs does.)
 
If you are talking about a typical situation that your PC simply controls a VXI-11 instrument through VISA with enabling Interrupt Channel callback capability (such as using viEnableEvent(SRQ)), VISA does not provide port mapper service for DEVICE_INTR channel.  The DEVICE_INTR channel is established for TCP/SOCKET connection, without using port mapper services.  In other words, most VXI-11 instruments will never post Port Mapper function for PMAPPROC_GETPORT (prog#395185 DEVICE_INTR).
 
See also the related thread:
 
Makoto
Message 2 of 8
(4,807 Views)

Hi Makoto

My question was directed as the option 2 of your reply where my PC with NI-VISA is talking to some VXI-11 instrument on a LAN network trough TCP/IP protocol.

I want to understand more your response. Tell me if my interpretation of your answer is correct.

<<The DEVICE_INTR channel is established for TCP/SOCKET connection, without using port mapper services.>>

AS NI-VISA does not support port mapper services at all my VXI-11 instruments must use TCP raw sockets to open the interrupt channel to the NI-VISA PC computer server that is waiting for SRQ event after this event has been enabled?

<<In other words, most VXI-11 instruments will never post Port Mapper function for PMAPPROC_GETPORT (prog#395185 DEVICE_INTR).>>

Currently our VXI-11 instrument developer is using RPC call libraries and is calling the RPC clnt_create(host, prognum, versnum, "tcp") to create a client that will post SRQ interrupts to NI-VISA TCP server but seems that as you say is not working with NI-VISA.

I think that using TCP raw sockets with NI-VISA is the only option in this case and we go that way for now to see if the SRQ interrupt channel could ever be open this way.

 

Thanks a lot for your expertise!

sorinvalea

 

 

 

0 Kudos
Message 3 of 8
(4,792 Views)

Hi Makoto

My previous reply to your answer was talking about a direct RPC call from the VXI-11 instrument back to NI-VISA server on Windows PC in order to open the interrupt channel required by the SRQ service.

1.Step 1

The PC IP address and TCP PortNumber# is passed to VXI-11 instrument by NI-VISA when SRQ is enabled trough a create_intr_chan RPC call.

2. Step2

The VXI-11 instrument tries to create a TCP client on the instrument side by using the RPC client create function with the [ hostaddress( PC IP address), prognum# , progversion# and "tcp"]  as input parameters.

3. Step3

The Port Mapper on the NI-VISA server side would be required to map the prognum# coming from this RPC call to the TCP PortNumber#.

Without a port mapper services on to match these two entities the call to create an interrupt channel fails as it happens currently.

 

Thanks

 

sorinvalea

 

 

 

0 Kudos
Message 4 of 8
(4,784 Views)

>>
AS NI-VISA does not support port mapper services at all my VXI-11 instruments must use TCP raw sockets to open the interrupt channel to the NI-VISA PC computer server that is waiting for SRQ event after this event has been enabled?
<<

Yes, your instrument must start connection for DEVICE_INTR channel using RAW SOCKET (STREAM).  As you can't use ONC RPC clnt_create(), and you should use the traditional BSD functions such as socket(AF_INET, SOCK_STREAM) and then connect().  But it is ***not*** meant that your instrument falls into "no-protocol" raw TCPIP interface.  Your instrument is still VXI-11.

>>
Currently our VXI-11 instrument developer is using RPC call libraries and is calling the RPC clnt_create(host, prognum, versnum, "tcp") to create a client that will post SRQ interrupts to NI-VISA TCP server but seems that as you say is not working with NI-VISA.
<<

Your instrument can't call clnt_create() for start the DEVICE_INTR connection, because clnt_create() function requires that the server-side (in this case, VISA) has to provide the Port Mapper services.  Use socket() and connect().

>>
1.Step 1
The PC IP address and TCP PortNumber# is passed to VXI-11 instrument by NI-VISA when SRQ is enabled trough a create_intr_chan RPC call.

2. Step2
The VXI-11 instrument tries to create a TCP client on the instrument side by using the RPC client create function with the [ hostaddress( PC IP address), prognum# , progversion# and "tcp"]  as input parameters.

3. Step3
The Port Mapper on the NI-VISA server side would be required to map the prognum# coming from this RPC call to the TCP PortNumber#.
<<

The Step1 is right, but the Step2 is not.  When starting DEVICE_INTR connection, the instrument, from inside the create_intr_chan() routine, should use socket() and connect().  When connecting, that target IP address and Port# must be the same values that are given by Device_RemoteFunc parameter on create_intr_chan() call.  Plus, mind that no data shall be sent to the host PC at the point of time. Your instrument shall start connection without sending any data, therefore don't call sendto() then.  It is normally guaranteed that the VISA software is already "accepting" on the specified port# before invoking create_intr_chan().  Normally connect() call from your instrument must succeed.  But if it has failed, the instrument create_intr_chan() shall return 6 (channel not established) as error status code.

Immediately after create_intr_chan() call, your instrument will be invoked on device_enable_srq() to enable it.  Then keep backup of the given handle<40> string, for the case the instrument will call device_intr_srq().

This approach does not require that the VISA software has to provide Port Mapper.  But when your instrument notifies an SRQ through device_intr_srq() function, your instrument must construct an emulated RPC header struct by hands.  (The DEVICE_INTR is still VXI-11 based, not a raw socket.)  In fact, a Remote Procedure Call is a pair of sendto() and recvfrom() operation.  Therefore, when SRQ is asserted, your instrument must call sendto() with RPCHDR and recvfrom() for the response sent back from VISA that will have REPLYHDR.

Then each traffic has a struct of RPC header in the beginning part.  On an RPC call through TCP/IP, the following headers are given before the opaque data entity, for RPC call and RPC reply respectively.  Each data field must be of Network-Byte-Order (= big endian).

typedef struct rcphdr
{
    uint32_t length; /*with MSB must be set*/
    uint32_t xid;         /* Transaction Identifier */
    uint32_t msg_type;    /* Message Type */
    uint32_t rpcvers;     /* RPC Version No. */
    uint32_t prog;        /* Program No. */
    uint32_t vers;        /* Program Version No. */
    uint32_t proc;        /* Procedure No. */
    uint32_t auth[4];   /*authentication data*/
} RPCHDR;

typedef struct replyhdr
{
    uint32_t length;
    uint32_t xid;
    uint32_t msg_type;
    uint32_t reply_status;
    uint32_t auth_type;
    uint32_t auth_len;
    uint32_t accepted_status;
} REPLYHDR;

As for authentication data, they can be all zero as probably your instrument does not implement authentication on DEVICE_INTR messages. 

The sendto()/recvfrom() call on device_intr_srq() is slightly simple.  I believe you can implement these structs on your raw socket calls through the DEVICE_INTR channel.  Any network SPY software can be used to view these traffic.  For a good reference, I recommend you to take a look with an actual LXI instrument.

 

Message 5 of 8
(4,764 Views)

Thanks Makoto

This last email answer to all my questions.

sorinvalea

0 Kudos
Message 6 of 8
(4,753 Views)

Let me correct one thing about device_intr_srq()

Makoto wrote:
>>
In fact, a Remote Procedure Call is a pair of sendto() and recvfrom() operation.  Therefore, when SRQ is asserted, your instrument must call sendto() with RPCHDR and recvfrom() for the response sent back from VISA that will have REPLYHDR.
<<

The device_intr_srq(), which will be invoked from instrument side, is a special case that the function is "one-way" RPC.  (The vxi11.x RPC definition file says the function is void return type.)  This means your instrument only has to call sendto() with RPCHDR data.  No need to call recvfrom() because it is void.

regards,
Makoto

0 Kudos
Message 7 of 8
(4,738 Views)

I have facing the same issue. I am able to establish interrupt channel with NI-Max client but still I am not getting VI_EVENT_SERVICE_REQ  event at NI-Visa client side  and viWaitonEvent() function giving timeout.

 

I have created new thread for my issue: -

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/How-to-create-the-VXI11-interrupt-channel-whi...

 

Please help.

0 Kudos
Message 8 of 8
(4,008 Views)