Giter Club home page Giter Club logo

rust-lxi-example's Introduction

Rust to LXI example

Simple example written in Rust that connects to LXI and prints Card_ID of specified card.

Status:

Setup

Tested on Windows 10 and openSUSE LEAP 15.3

Setup: Windows

You need to have installed:

Following components were used:

C:\> rustup -V

rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.60.0 (7737e0b5c 2022-04-04)`

C:\> rustup toolchain list

stable-x86_64-pc-windows-msvc (default)

C:\> rustc -V
rustc 1.60.0 (7737e0b5c 2022-04-04)

C:\> cargo -V
 
cargo 1.60.0 (d1fd9fe2c 2022-03-01)

Windows: Building application:

Open CMD and issue these commands:

rem if build fails with weird w2_sock32.lib error try this:
"c:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"

rem build command
cargo build

To run this program invoke (replace 192.168.56.101 with IP Address of your LXI Simulator):

cargo run -- -l 192.168.56.101 -b 1 -s 15

Example output:

Program version: 64-bit Debug
Picmlx Raw Version is: 1183
Picmlx Ex Version: CbVersionInfo { major: 1, minor: 18, patch: 3 }
Piplx Raw Version is: 1172
Piplx Ex Version: CbVersionInfo { major: 1, minor: 17, patch: 2 }
Connecting to LXI on 192.168.56.101:1024...
Got Session: 23867
Opening Card at Bus=1 Slot=15
Got CardNum=1
Card ID is '40-160-001,1000000,1.01'
Cleanup: Closing card `PiplxHandle { card_num: 1, picmlx_handle: PicmlxHandle { sid: 23867 } }`...
Cleanup: Done. Card with CardNum=1 closed.
Cleanup: Closing session `PicmlxHandle { sid: 23867 }`...
Cleanup: Done. Session 23867 closed.
Done, exiting...

Windows: 32-bit build

It does not work - on build I get mismatch of 32 and 64 bit target for link.exe. Also see: https://users.rust-lang.org/t/how-to-build-both-32-and-64-bit-app-on-windows/26365

So please stick to 64-bit MSVC target.

Experimental support. You need likely to add 32-bit target first using (from https://users.rust-lang.org/t/how-to-build-both-32-and-64-bit-app-on-windows/26365):

rustup target add i686-pc-windows-msvc

And then invoke cargo with target parameter

cargo build --target=i686-pc-windows-msvc

Setup: Linux

Tested on openSUSE LEAP 15.3:

You need:

sudo zypper in cargo
  • install ClientBridge/C++ library for Linux:
    • Download latest ClientBridge for Linux from (used "Debian" for OpenSUSE - more up to date than RedHat versions):

    • https://downloads.pickeringtest.info/downloads/drivers/Sys60/Linux/ClientBridge/Debian/

    • unpack downloaded version and create necessary symlinks, for example:

      cd
      curl -fLO https://downloads.pickeringtest.info/downloads/drivers/Sys60/Linux/ClientBridge/\
      Debian/ClientBridge-1.64.0.0-amd64_deb.tar.gz
      tar xvzf ClientBridge-1.64.0.0-amd64_deb.tar.gz ./usr/lib
      sudo cp usr/lib/libpi*.so* /usr/local/lib/64
      cd /usr/local/lib64/
      sudo ln -s libpicmlx.so.1.18.2 libpicmlx.so
      sudo ln -s libpiplx.so.1.17.1 libpiplx.so

WARNING! It is less than ideal to (mis)use Debian builds for openSUSE but we have no binary packages for SUSE yet. Here we prefer Debian builds over Redhat builds because they are up-to-date.

Now back in this project directory use command cargo build to build example binary

You can run this binary using command like:

cargo run -- -l IP_OF_LXI_SIMULATOR -b 1 -s 15

Example output:

cargo run -- -l 192.168.100.192 -b 1 -s 15
   Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rust-lxi-example -l 192.168.100.192 -b 1 -s 15`
Program version: 64-bit Debug
Picmlx Raw Version is: 1182
Picmlx Ex Version: CbVersionInfo { major: 1, minor: 18, patch: 2 }
Piplx Raw Version is: 1171
Piplx Ex Version: CbVersionInfo { major: 1, minor: 17, patch: 1 }
Connecting to LXI on 192.168.100.192:1024...
Got Session: 332792694
Opening Card at Bus=1 Slot=15
Got CardNum=1
Card ID is '40-160-001,1000000,1.01'
Cleanup: Closing card `PiplxHandle { card_num: 1, picmlx_handle: PicmlxHandle { sid: 332792694 } }`...
Cleanup: Done. Card with CardNum=1 closed.
Cleanup: Closing session `PicmlxHandle { sid: 332792694 }`...
Cleanup: Done. Session 332792694 closed.
Done, exiting...

= Resources

rust-lxi-example's People

Contributors

hpaluch-pil avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.