.\" man page for Munts Technologies Linux Simple I/O Library .\" .\" Copyright (C)2016-2023, Philip Munts dba Munts Technologies. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" .\" * Redistributions of source code must retain the above copyright notice, .\" this list of conditions and the following disclaimer. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .TH liblinx 2 "21 December 2018" "version 1" "Linux Simple I/O Library" .SH NAME .B liblinx \-\- Linux Simple I/O Library: LabView LINX Remote I/O Module .SH SYNOPSIS .nf .B #include Structures: .BI "typedef struct" .BI "{" .BI " uint8_t " SoF ";" .BI " uint8_t " PacketSize ";" .BI " uint16_t " PacketNum ";" .BI " uint16_t " Command ";" .BI " uint8_t " Args[54] ";" .BI "} " LINX_command_t ";" .BI "typedef struct" .BI "{" .BI " uint8_t " SoF ";" .BI " uint8_t " PacketSize ";" .BI " uint16_t " PacketNum ";" .BI " uint8_t " Status ";" .BI " uint8_t " Data[55] ";" .BI "} " LINX_response_t ";" Server Routines: .BI "void LINX_receive_command(int32_t " fd ", LINX_command_t *" cmd ", int32_t *" count ", int32_t *" error ");" .BI "void LINX_transmit_response(int32_t " fd ", LINX_response_t *" resp ", int32_t *" error ");" Client Routines: .BI "void LINX_transmit_command(int32_t " fd ", LINX_command_t *" cmd ", int32_t *" error ");" .BI "void LINX_receive_response(int32_t " fd ", LINX_response_t *" resp ", int32_t *" count ", int32_t *" error ");" Byte Packing Routines: .BI "uint16_t LINX_makeu16(uint8_t " b0 ", uint8_t " b1 ");" .BI "uint32_t LINX_makeu32(uint8_t " b0 ", uint8_t " b1, " uint8_t " b2 ", uint8_t " b3 ");" Byte Unpacking Routines: .BI "uint8_t LINX_splitu16(uint16_t " u16 ", int32_t " bn ");" .BI "uint8_t LINX_splitu32(uint32_t " u32 ", int32_t " bn ");" .fi Link with .BR -lsimpleio . .SH DESCRIPTION .nh These routines perform framing and encoding or decoding of LabView LINX remote I/O commands (from client to server) and responses (from server to client) to and from a bidirectional byte stream, which will typically be either a serial port or a network socket. .PP The transmit routines encode a frame from a command or response structure and write it to the stream indicated by the stream file descriptor .IR fd . If the frame was written to the stream successfully, .IR *error will be set to zero, otherwise it will be set to an .B errno value. .PP The receive routines read exactly one byte from the stream indicated by the stream file descriptor .IR fd . If the byte was read successfully and completes a frame, .IR *error will be set to zero. If a byte was read successfully, but did not complete a frame, .IR *error will be set to .B EAGAIN. If the read failed, .IR *error will be set to an .B errno value and the previous data discarded. Successive calls to each receive routine must pass the same command or response structure. The .IR *count parameter preserves a byte counter between successive function calls. .PP A LINX server running on some hardware device will typically have a message loop that calls .B LINX_receive_command() to get each command from the LINX client, do some work, and then call .B LINX_transmit_response() to return results to the client. .PP A LINX client will typically call .B LINX_transmit_command() to send each command to the server and immediately thereafter call .B LINX_receive_response() to receive the results from the server. .PP The byte packing routines .B LINX_makeu16() "and " LINX_makeu32() pack two or four unsigned bytes into a 16-bit or 32-bit unsigned integer. .IR b0 is the most significant byte and .IR b1 " or " b3 is the least significant byte. .PP The byte unpacking routines .B LINX_splitu16() and LINX_splitu32() return a signle unsigned byte of a 16-bit or 32-bit unsigned integer, selected by the .IR bn byte index parameter. A byte index of .B 0 selects the most significant byte and a byte index of .BR 1 " or " 3 selects the least significant byte. .SH SEE ALSO .BR libsimpleio "(2), " libadc "(2), " libdac "(2), " libevent "(2), " libgpio "(2)," .br .BR libhidraw "(2), " libi2c "(2), " libipv4 "(2), " liblinux "(2), " libpwm "(2)," .br .BR libserial "(2), " libspi "(2), " libstream "(2), " libwatchdog "(2)" .PP .B https://www.labviewmakerhub.com/doku.php?id=learn:libraries:linx:spec:start .SH AUTHOR Philip Munts dba Munts Technologies.