rasProject_01 / weSweetHome  R. 240
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
weSerial.h File Reference

Definitions for Raspberry Pi's serial communication. More...

#include "arch/config.h"
#include <termios.h>
#include "sysBasic.h"
#include <fcntl.h>

Functions

tcflag_t baudFlag (unsigned int const speed)
 Baud flags by baud rate. More...
 
unsigned int baudRate (tcflag_t baudFlag)
 Baud rate by baud flags. More...
 
void closeUART ()
 Close the UART. More...
 
int openUART ()
 Open the UART with given settings. More...
 

Variables

tcflag_t baud
 The UART's baud rate as flag bits.
 
struct termios options
 The UART's setting structure.
 
unsigned int speed
 The UART's baud rate as value.
 
timespec startReceive
 Time used for receive timing.
 
int uartFilestream
 The UART as file (stream). More...
 
char * uartPath
 The UART's path name. More...
 

Detailed Description

Definitions for Raspberry Pi's serial communication.

Copyright (c) 2019 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 255 29.10.2023
Rev. 209 09.07.2019 : new

This is a (basic) library for serial communications. As far as Modbus is or can be supported this is independent of Stéphane Raimbault's Modbus library libmodbus; weModbus.h on the other hand is.

Some structures and utilities are to support smart meters like e.g. SDM230Modbus, SMD630Modbus and SDM538Modbus as servers/slaves, especially their handling of (32 bit) float values.

Function Documentation

◆ baudFlag()

tcflag_t baudFlag ( unsigned int const  speed)

Baud flags by baud rate.

Parameters
speeda legal baudrate 300 9600 19200 and so on
Returns
the corresponding flag bits if rate is available; otherwise 0 (error). This should be defaulted to a standard rate like 9600 e.g.

◆ baudRate()

unsigned int baudRate ( tcflag_t  baudFlag)

Baud rate by baud flags.

The speed bits of the parameter baudFlag will be evaluated and the corresponding baud rate will be returned. In vase of no valid speed flag value 0 will be returned. 0 may be considered as error and should be defaulted to 9600.

Parameters
baudFlagthe speed bits of the flags parameter will be evaluated
Returns
the corresponding baud rate 300, 9600, 19200 or other standard rate

◆ openUART()

int openUART ( )

Open the UART with given settings.

Returns
uartFilestream; -1 means open error

◆ closeUART()

void closeUART ( )

Close the UART.

uartFilestream will be set to -1.

Variable Documentation

◆ uartFilestream

int uartFilestream
extern

The UART as file (stream).

It is > 0 (>2) when open and -1 when closed.

◆ uartPath

char* uartPath
extern

The UART's path name.

It will be preset with the architecture's standard UART path.