TI-RTOS vxi11 儀器服務的實現_part1

參考連結:

http://bbs.eeworld.com.cn/thread-526055-1-1.html

前言(垃圾話)

LXI 設備: 符合 LXI 規範的儀器設備,我的理解是用網口通信的儀器設備就是 LXI 設備
VXI-11:控制器和設備通過 TCP/IP 網絡通信的網絡儀器協儀
RPC:遠程調用,基於 C/S 模型,一台計算機上的程序調用另一台計算機上的程序
XDR:外部數據表示,就是在不同的計算機系統中轉換數據的格式,避免出現類似大小端的問題
TI: 德州儀器 (Texas Instruments) 德州儀器是一家位於美國德克薩斯州達拉斯的跨國公司,以開發、製造、銷售半導體和計算機技術聞名於世,主要從事數位訊號處理與類比電路方面的研究、製造和銷售。它在 25 個國家有製造、設計或者銷售機構。

國家儀器股份有限公司(英語:National Instruments,縮寫 NI,NASDAQ:NATI)是一家美國公司,從事與測試、控制、設計領域相關的,包括虛擬儀器和電子測試設備等工程軟體的開發。著名產品有圖形開發環境 LabVIEW、C 語言虛擬儀器應用系統 LabWindows/CVI、集成電路分析程序 NI Multisim 等等;硬體產品包括 VXI 匯流排、PXI 匯流排、VME 匯流排的框架與模塊,IEEE-488 接口以及內部整合電路和其他自動化技術的標準

Issue:
Implementing VXI-11 protocol in existing serial to ethernet for LXI compatibility
TI 的客戶曾經請求官方提供 vxi11 功能,但官方回應不支援,並鎖定討論串,有夠 777777,最後一篇原 PO 者還貼了一堆資訊然後就討論串被鎖了,當然我也是笑不出來啦,因為換我要開發這鬼咚咚。

回到正題,簡單來說 VXI-11 實現需要執行兩個服務,一個是 portmap service (port:111),vxi11 service(port: range~range,range 根據 rpc code 是根據程式 pid 隨機產生出來的,所以就隨便定)。去 ni-visa 官網下載 ni-MAX,

相關文件

文件部分請參考我的 github

vxi11.x

typedef long Device_Link;

enum Device_AddrFamily
{
    DEVICE_TCP,
    DEVICE_UDP
};

typedef long Device_Flags;

typedef long Device_ErrorCode;

struct Device_Error
{
    Device_ErrorCode error;
};

struct Create_LinkParms
{
    long            clientId;        /* implementation specific value */
    bool            lockDevice;        /* attempt to lock the device */
    unsigned long        lock_timeout;        /* time to wait for lock */
    string            device<>;        /* name of device */
};
struct Create_LinkResp
{
    Device_ErrorCode    error;
    Device_Link        lid;
    unsigned short        abortPort;        /* for the abort RPC */
    unsigned long        maxRecvSize;        /* max # of bytes accepted on write */
};
struct Device_WriteParms
{
    Device_Link        lid;            /* link id from create_link */
    unsigned long        io_timeout;        /* time to wait for I/O */
    unsigned long        lock_timeout;        /* time to wait for lock */
    Device_Flags        flags;            /* flags with options */
    opaque            data<>;            /* the data length and the data itself */
};
struct Device_WriteResp
{
    Device_ErrorCode    error;
    unsigned long        size;            /* # of bytes written */
};
struct Device_ReadParms
{
    Device_Link        lid;            /* link id from create_link */
    unsigned long        requestSize;        /* # of bytes requested */
    unsigned long        io_timeout;        /* time to wait for I/O */
    unsigned long        lock_timeout;        /* time to wait for lock */
    Device_Flags        flags;            /* flags with options */
    char            termChar;        /* valid if flags & termchrset */
};
struct Device_ReadResp
{
    Device_ErrorCode    error;
    long            reason;            /* why read completed */
    opaque            data<>;            /* the data length and the data itself */
};
struct Device_ReadStbResp
{
    Device_ErrorCode    error;
    unsigned char        stb;            /* the returned status byte */
};
struct Device_GenericParms
{
    Device_Link        lid;            /* link id from create_link */
    Device_Flags        flags;            /* flags with options */
    unsigned long        lock_timeout;        /* time to wait for lock */
    unsigned long        io_timeout;        /* time to wait for I/O */
};
struct Device_RemoteFunc
{
    unsigned long        hostAddr;        /* host servicing interrupt */
    unsigned long        hostPort;        /* valid port # on client */
    unsigned long        progNum;        /* DEVICE_INTR */
    unsigned long        progVers;        /* DEVICE_INTR_VERSION */
    Device_AddrFamily    progFamily;        /* DEVICE_UDP | DEVICE_TCP */
};
struct Device_EnableSrqParms
{
    Device_Link        lid;            /* link id from create_link */
    bool            enable;            /* enable or disable intr's */
    opaque            handle<40>;        /* host specific data */
};
struct Device_LockParms
{
    Device_Link        lid;            /* link id from create_link */
    Device_Flags        flags;            /* contains the waitlock flag */
    unsigned long        lock_timeout;        /* time to wait for lock */
};
struct Device_DocmdParms
{
    Device_Link        lid;            /* link id from create_link */
    Device_Flags        flags;            /* flags with options */
    unsigned long        io_timeout;        /* time to wait for I/O */
    unsigned long        lock_timeout;        /* time to wait for lock */
    long            cmd;            /* which command to execute */
    bool            network_order;        /* client's byte order */
    long            datasize;        /* size of individual data elements */
    opaque            data_in<>;        /* docmd data parameters */
};
struct Device_DocmdResp
{
    Device_ErrorCode    error;
    opaque            data_out<>;        /* returned data parameters */
};

program DEVICE_ASYNC
{
    version DEVICE_ASYNC_VERSION
    {
        Device_Error        device_abort        (Device_Link)        = 1;
    } = 1;
} = 0x0607B0;

program DEVICE_CORE
{
    version DEVICE_CORE_VERSION
    {
        Create_LinkResp        create_link        (Create_LinkParms)    = 10;
        Device_WriteResp    device_write        (Device_WriteParms)    = 11;
        Device_ReadResp        device_read        (Device_ReadParms)    = 12;
        Device_ReadStbResp    device_readstb        (Device_GenericParms)    = 13;
        Device_Error        device_trigger        (Device_GenericParms)    = 14;
        Device_Error        device_clear        (Device_GenericParms)    = 15;
        Device_Error        device_remote        (Device_GenericParms)    = 16;
        Device_Error        device_local        (Device_GenericParms)    = 17;
        Device_Error        device_lock        (Device_LockParms)    = 18;
        Device_Error        device_unlock        (Device_Link)        = 19;
        Device_Error        device_enable_srq    (Device_EnableSrqParms)    = 20;
        Device_DocmdResp    device_docmd        (Device_DocmdParms)    = 22;
        Device_Error        destroy_link        (Device_Link)        = 23;
        Device_Error        create_intr_chan    (Device_RemoteFunc)    = 25;
        Device_Error        destroy_intr_chan    (void)            = 26;
    } = 1;
} = 0x0607AF;

/******************************************************************************
 *
 * vxi11intr.rpcl
 *
 *    This file is best viewed with a tabwidth of 4
 *
 ******************************************************************************
 *
 * TODO:
 *
 ******************************************************************************
 *
 *    Original Author:    someone from VXIbus Consortium
 *    Current Author:        Benjamin Franksen
 *    Date:                03-06-97
 *
 *    RPCL description of the intr-channel of the TCP/IP Instrument Protocol
 *    Specification.
 *
 *
 * Modification Log:
 * -----------------
 * .00    03-06-97    bfr        created this file
 *
 ******************************************************************************
 *
 * Notes:
 *
 *    This stuff is literally from
 *
 *        "VXI-11, Ref 1.0 : TCP/IP Instrument Protocol Specification"
 *
 */

struct Device_SrqParms
{
    opaque    handle<>;
};

program DEVICE_INTR
{
    version DEVICE_INTR_VERSION
    {
        void            device_intr_srq        (Device_SrqParms)    = 30;
    } = 1;
} = 0x0607B1;

clone 示範代碼

$git clone http://172.16.5.187:10080/tsaiyuyan/oncrpc_project.git

$tree

├─oncrpc_ti-rtos_gw (被tsaiyuyan 移植到 TI-RTOS)
│  ├─include    <==> rpc header files (被tsaiyuyan 修改過)
│  │  └─rpc
│  ├─portmap    <==> rpc source code  (被tsaiyuyan 修改過)
│  ├─src        <==> rpc source code  (被tsaiyuyan 修改過)
│  └─vxi11      <==> vxi11 source code  (被tsaiyuyan 修改過)
└─oncrpc_win_gw (原始碼)
    ├─include   <==> rpc header files
    │  └─rpc
    ├─portmap   <==> rpc source code
    ├─src       <==> rpc source code
    ├─vxi11     <==> vxi11 source code
    └─vxi11_x   <==> 有個 vxi11.x 為官網提供的模板搭配 rpcgen.exe 使用,
                     vxi11 這個folder 的檔案就是靠 rpcgen 產生的。

如何使用 rpcgen for vxi11.x

請參閱影片: https://youtu.be/haqsQjkJ90M

vxi11 在 windows 示範

請參閱影片: https://youtu.be/HD1JY9mEhRI

移植 vxi11 到 TI-RTOS 上

  1. 請參考下篇文章 vxi11 儀器服務的實現_part2

  2. 用 winmerge 比較 oncrpc_ti-rtos_gw 跟 oncrpc_win_gw 這兩個資料夾


 上一篇
下一篇 
Vmware Windows虛擬機減肥筆記 Vmware Windows虛擬機減肥筆記
有一天手賤,把vmware的windows OS disk extend 至120G空間,然後儲存過60G的資料,實際上只有吃22G左右,但是不管用網路上的方式清理還是重組都是無效,未使用區域填0也沒啥效果。
2020-04-07
  目錄