Public Repository

Last pushed: a year ago
Short Description
development environment to work with CaenRFID UHF reader using Cosino client side protocol API
Full Description

This docker offer a development environment to work with CaenRFID UHF reader

It is based on Cosino client side protocol API from https://github.com/cosino

Usage :

launch the docker :

 # docker run -t -i \
    -v $(pwd):/root/projects \
   --rm caenrfid-reader-dev:latest  /bin/bash

compile C project :

# gcc -Wall your_prog.c -std=c99 -lcaenrfid -o your_prog

run python script (sadly only python2):

# python your_script.py

C sample :

/* Sample */
#include <stdio.h>
#include <stdlib.h>
#include <caenrfid.h>
#include <math.h>

int main(int argc, char** argv) {
   int ret;
   struct caenrfid_handle handle;
   int OutPower;
   double ERPPower;
   double Gain = 8.0;
   double Loss = 1.5;

   // Start a new connection with the CAENRFIDD server
 ret = caenrfid_open(CAENRFID_PORT_TCP, "192.168.1.31", &handle);
 if(ret < 0){
     fprintf(stderr, "cannot init lib (err=%d)\n", ret);
     return (EXIT_FAILURE);
 }

 // Get power
 ret = caenrfid_get_power(&handle,&OutPower);
 if(ret < 0){
     fprintf(stderr, "cannot read power (err=%d)\n", ret);
     return (EXIT_FAILURE);
 }

 // Close connection
 ret = caenrfid_close(&handle);
 if (ret < 0){
     fprintf(stderr, "improper caenrfidlib closure!\n");
     return (EXIT_FAILURE);
 }
 return (EXIT_SUCCESS);
}

Python sample :

#!/usr/bin/env python

import os, sys
import caenrfidc

NAME = os.path.basename(sys.argv[0])
if len(sys.argv) < 2 :
    sys.exit('usage: %s server' % NAME)

h = caenrfidc.open(sys.argv[1])

print "inventory data:"
print caenrfidc.inventory(h, "Source_0")

caenrfidc.close(h)

Dockerfile :

FROM debian:jessie

RUN apt-get update && \
        apt-get install -y git \
        make gcc debhelper dctrl-tools \
        libtool dh-autoreconf \
        python libpython-dev python-pip\
    && rm -rf /var/lib/apt/lists/*

RUN cd /root && \
    git clone git://github.com/selinux/libmsgbuff.git && \
    git clone git://github.com/selinux/libavp.git && \
    git clone git://github.com/selinux/libcaenrfid.git && \
    git clone git://github.com/selinux/caenrfidc-python.git && \
    for dir in libmsgbuff libavp libcaenrfid; \
        do cd $dir &&\
        ./autogen.sh &&\
        ./debian/rules binary && cd .. &&\
        dpkg -i ${dir}*.deb;\
    done

RUN cd /root/caenrfidc-python && \
    python setup.py build && \
    python setup.py install

RUN mkdir /root/projects
Docker Pull Command
Owner
selinux

Comments (0)