Giter Club home page Giter Club logo

xfp's Introduction

The XFP application

Authors: Thiago Esteves ([email protected]).

Note

The XFP application is dependent on GPROC library and the low level functions implemented at c_src/xfp_driver.c are just for test purposes (stubbed) and must be replace for the real accessors.

Introduction

The XFP is a transceiver for high-speed computer network and telecommunication links that use optical fiber. It is largely used in telecommunications equipment and the code here is an example of how Erlang language can be used to handle eletronic devices with a wrapper to the basic fucntions (i2c, uart, spi, etc).

The driver is using the polling format to read the presence pin every 1 second which means that it will take up to 1 second to detect any changes. Once the device is inserted, all the static information is read and saved in its state.

Compiling and Running

To compile and run for your machine just call the following command in the CLI:

$ make

Use case: Creating XFP devices

The user can create as many device as needed (the stub supports only 20, but with the real hardware there is no limitation):

1> xfp_sup:create_xfp(0).
{ok,<0.167.0>}
2> xfp:get_temperature(0).
{ok,6.25}
3> xfp:get_state(0).
{xfp_data,0,true,6,"VENDOR NAME  XFP",0,32,
          "VENDOR PARTNUMBE","01",1310.0,"VENDOR SERIALNUM",
          "DATACODE",255,85,255}
4> xfp:get_laser_state(0).
{ok,1}
5> xfp_sup:delete_xfp(0).
ok

Stub: Emulating Insertion/Removal of the XFP

In order to test the capture of the insertion or the removal of the device you can write in the presence pin to simulate this condition as the example below:

1> xfp_sup:create_xfp(0).
{ok,<0.167.0>}
2> xfp:get_state(0).
{xfp_data,0,true,6,"VENDOR NAME  XFP",0,32,
          "VENDOR PARTNUMBE","01",1310.0,"VENDOR SERIALNUM",
          "DATACODE",255,85,255}
3> xfp_driver:write_pin(0,2,1).
{ok,0}
4> xfp:get_state(0).
{xfp_data,0,false,undefined,undefined,undefined,undefined,
          undefined,undefined,undefined,undefined,undefined,undefined,
          undefined,undefined}

Supervisor tree

The supervisor tree of all XFP's created can be easily viewed with the observer, try the sequence of commands below and have a look at the Applications->xfp.

1> xfp_sup:create_xfp(0).
{ok,<0.167.0>}
2> xfp_sup:create_xfp(1).
{ok,<0.169.0>}
3> xfp_sup:create_xfp(2).
{ok,<0.171.0>}
4> xfp_sup:create_xfp(3).
{ok,<0.173.0>}
5> xfp_sup:create_xfp(4).
{ok,<0.175.0>}
6> xfp_sup:create_xfp(5).
{ok,<0.177.0>}
7> observer:start().
ok

Erlang Code References

http://erlang.org/doc/tutorial/c_port.html http://erlang.org/doc/reference_manual/ports.html https://github.com/massemanet/inotify

XFP References

https://www.gigalight.com/downloads/standards/INF-8077i.pdf https://en.wikipedia.org/wiki/XFP_transceiver

xfp's People

Contributors

thiagoesteves avatar

Stargazers

 avatar

Watchers

 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.