libmsr  dc2dc9c
Functions
serialio.c File Reference
#include <sys/types.h>
#include <sys/fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <err.h>
#include "libmsr.h"
Include dependency graph for serialio.c:

Functions

int msr_serial_readchar (int fd, uint8_t *c)
 Read a single character from the MSR device. More...
 
int msr_serial_read (int fd, void *buf, size_t len)
 Read a series of bytes from the MSR device. More...
 
int msr_serial_write (int fd, void *buf, size_t len)
 Write a series of bytes to the MSR device. More...
 
int msr_serial_open (char *path, int *fd, int blocking, speed_t baud)
 Open a serial connection to the MSR device. More...
 
int msr_serial_close (int fd)
 Close a serial connection to the MSR device. More...
 

Function Documentation

◆ msr_serial_close()

int msr_serial_close ( int  fd)

Close a serial connection to the MSR device.

Parameters
fdThe file descriptor to close.
Returns
LIBMSR_ERR_OK

◆ msr_serial_open()

int msr_serial_open ( char *  path,
int *  fd,
int  blocking,
speed_t  baud 
)

Open a serial connection to the MSR device.

Parameters
pathThe path to the serial device.
fdThe int pointer to store the file descriptor in.
blockingThe blocking flag (e.g., MSR_BLOCKING)
baudThe baud rate of the serial device (e.g., MSR_BAUD)
Returns
LIBMSR_ERR_OK on success
LIBMSR_ERR_SERIAL on failure

◆ msr_serial_read()

int msr_serial_read ( int  fd,
void *  buf,
size_t  len 
)

Read a series of bytes from the MSR device.

Parameters
fdThe file descriptor to read from.
bufThe buffer to read into.
lenThe length of the buffer.
Returns
LIBMSR_ERR_OK

◆ msr_serial_readchar()

int msr_serial_readchar ( int  fd,
uint8_t *  c 
)

Read a single character from the MSR device.

Parameters
fdThe file descriptor to read from.
cA pointer to write the character into.
Returns
The character read

◆ msr_serial_write()

int msr_serial_write ( int  fd,
void *  buf,
size_t  len 
)

Write a series of bytes to the MSR device.

Parameters
fdThe file descriptor to write to.
bufThe buffer to write.
lenThe length of the buffer.
Returns
The number of bytes written, or -1 on error.