Skip to content

Commit

Permalink
Require full name for serial devices, e.g. /dev/ttyAMA0 rather than t…
Browse files Browse the repository at this point in the history
…tyAMA0.
  • Loading branch information
joan2937 committed Apr 16, 2021
1 parent a0dbc99 commit 8f385c9
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 60 deletions.
8 changes: 4 additions & 4 deletions CFG/permits
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ test2=n
test3=y

[serial]
default=serial0
test1=serial*:ttyUSB*:ttyS*
test2=ttyUSB1:tty0:ttyS0
test3=null
default=/dev/serial0
test1=/dev/serial*:/dev/ttyUSB*:/dev/ttyS*
test2=/dev/ttyUSB1:/dev/tty0:/dev/ttyS0
test3=/dev/null

[spi]
default=0.*
Expand Down
Binary file modified DOC/dbase/lg.sqlite
Binary file not shown.
17 changes: 9 additions & 8 deletions DOC/src/defs/permits.def
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ TEXT*/

/*TEXT [serial]
Each entry in this section takes the form [#user=device#] where
[#device#] indicates a serial device. E.g. [#serial0#] refers to
[#device#] indicates a serial device. E.g. [#/dev/serial0#] refers to
Linux device [#/dev/serial0#]

There may be more than one [#device#] entry per user, each must be separated by a [#:#] character.
Expand All @@ -216,10 +216,11 @@ There may be more than one [#device#] entry per user, each must be separated by
characters) or [#?#] (matches a single character).

...
fred=serial0 # user fred can access /dev/serial0.
peter=tty* # user peter can access /dev/tty*.
boss=* # user boss can access /dev/*.
sally=serial?:ttyS* # user sally can access /dev/serial? and /dev/ttyS*.
fred=/dev/serial0 # user fred can access /dev/serial0.
peter=/dev/tty* # user peter can access /dev/tty*.
boss=/dev/* # user boss can access /dev/*.
sally=/dev/serial?:/dev/ttyS* # user sally can access /dev/serial?
# and /dev/ttyS*.
...

TEXT*/
Expand Down Expand Up @@ -292,9 +293,9 @@ test2=n
test3=y

[serial]
test1=serial*:ttyUSB*:ttyS*
test2=ttyUSB1:tty0:ttyS0
test3=null
test1=/dev/serial*:/dev/ttyUSB*:/dev/ttyS*
test2=/dev/ttyUSB1:/dev/tty0:/dev/ttyS0
test3=/dev/null

[spi]
test1=0.0:0.1:1.0:1.1:1.2:2.0:2.1
Expand Down
15 changes: 7 additions & 8 deletions DOC/src/defs/rgs.def
Original file line number Diff line number Diff line change
Expand Up @@ -1396,10 +1396,10 @@ The baud rate must be one of 50, 75, 110, 134, 150,
38400, 57600, 115200, or 230400.

...
$ rgs sero ttyAMA0 9600 0
$ rgs sero /dev/ttyAMA0 9600 0
0

$ rgs sero tty1 38400 0
$ rgs sero /dev/tty1 38400 0
1
...

Expand Down Expand Up @@ -1794,14 +1794,13 @@ cyc :: >= 0
The number of PWM pulses to generate. A value of 0 means infinite.

dev :: a tty serial device
The command expects the name of a serial device without the
leading /dev, e.g.
The command expects the name of a serial device, e.g.

...
ttyAMA0
ttyUSB0
tty0
serial0
/dev/ttyAMA0
/dev/ttyUSB0
/dev/tty0
/dev/serial0
...

ef :: GPIO event flags
Expand Down
12 changes: 6 additions & 6 deletions PY_LGPIO/lgpio_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import threading
import time

LGPIO_PY_VERSION = 0x00010001
LGPIO_PY_VERSION = 0x00010700

exceptions = True

Expand Down Expand Up @@ -1738,7 +1738,7 @@ def notify_close(handle):
def serial_open(tty, baud, ser_flags=0):
"""
Returns a handle for the serial tty device opened
at baud bits per second. The device muse be in /dev.
at baud bits per second.
tty:= the serial device to open.
baud:= baud rate in bits per second, see below.
Expand All @@ -1753,11 +1753,11 @@ def serial_open(tty, baud, ser_flags=0):
38400, 57600, 115200, or 230400.
...
h1 = sbc.serial_open("ttyAMA0", 300)
h1 = sbc.serial_open("/dev/ttyAMA0", 300)
h2 = sbc.serial_open("ttyUSB1", 19200, 0)
h2 = sbc.serial_open("/dev/ttyUSB1", 19200, 0)
h3 = sbc.serial_open("serial0", 9600)
h3 = sbc.serial_open("/dev/serial0", 9600)
...
"""
return _u2i(_lgpio._serial_open(tty, baud, ser_flags))
Expand Down Expand Up @@ -2234,7 +2234,7 @@ class with the following members.
See [*spi_open*].
tty:
A serial device, e.g. ttyAMA0, ttyUSB0
A serial device, e.g. /dev/ttyAMA0, /dev/ttyUSB0
uint32:
An unsigned 32 bit number.
Expand Down
2 changes: 1 addition & 1 deletion PY_LGPIO/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
lgpio_module = Extension('_lgpio', sources=['lgpio_wrap.c',], libraries=['lgpio',],)

setup (name = 'lgpio',
version = '0.1.0.1',
version = '0.1.7.0',
zip_safe=False,
author='joan',
author_email='[email protected]',
Expand Down
12 changes: 6 additions & 6 deletions PY_RGPIO/rgpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
import atexit
import hashlib

RGPIO_PY_VERSION = 0x00010100
RGPIO_PY_VERSION = 0x00010700

exceptions = True

Expand Down Expand Up @@ -2937,7 +2937,7 @@ def script_delete(self, handle):
def serial_open(self, tty, baud, ser_flags=0):
"""
Returns a handle for the serial tty device opened
at baud bits per second. The device muse be in /dev.
at baud bits per second.
This is a privileged command. See [+Permits+].
Expand All @@ -2954,11 +2954,11 @@ def serial_open(self, tty, baud, ser_flags=0):
38400, 57600, 115200, or 230400.
...
h1 = sbc.serial_open("ttyAMA0", 300)
h1 = sbc.serial_open("/dev/ttyAMA0", 300)
h2 = sbc.serial_open("ttyUSB1", 19200, 0)
h2 = sbc.serial_open("/dev/ttyUSB1", 19200, 0)
h3 = sbc.serial_open("serial0", 9600)
h3 = sbc.serial_open("/dev/serial0", 9600)
...
"""
ext = [struct.pack("II", baud, ser_flags)] + [tty]
Expand Down Expand Up @@ -3755,7 +3755,7 @@ class with the following members.
See [*spi_open*].
tty:
A serial device, e.g. ttyAMA0, ttyUSB0
A serial device, e.g. /dev/ttyAMA0, /dev/ttyUSB0
uint32:
An unsigned 32 bit number.
Expand Down
2 changes: 1 addition & 1 deletion PY_RGPIO/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = f.read()

setup(name='rgpio',
version='0.1.1.0',
version='0.1.7.0',
zip_safe=False,
author='joan',
author_email='[email protected]',
Expand Down
5 changes: 1 addition & 4 deletions lgSerial.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ int lgSerialOpen(const char *serDev, int serBaud, int serFlags)
int speed;
int fd;
int handle;
char serName[LG_MAX_PATH];
lgSerialObj_p ser;

LG_DBG(LG_DEBUG_TRACE, "serDev=%s serBaud=%d serFlags=0x%X",
Expand Down Expand Up @@ -90,9 +89,7 @@ int lgSerialOpen(const char *serDev, int serBaud, int serFlags)
if (serFlags)
PARAM_ERROR(LG_BAD_SERIAL_FLAGS, "bad serial flags (0x%X)", serFlags);

snprintf(serName, LG_MAX_PATH, "/dev/%s", serDev);

if ((fd = open(serName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) == -1)
if ((fd = open(serDev, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) == -1)
{
return LG_SERIAL_OPEN_FAILED;
}
Expand Down
2 changes: 1 addition & 1 deletion lgpio.3
Original file line number Diff line number Diff line change
Expand Up @@ -3432,7 +3432,7 @@ End
.IP "\fBint lgSerialOpen(const char *serDev, int serBaud, int serFlags)\fP"
.IP "" 4
This function opens a serial device at a specified baud rate
and with specified flags. The device must be present in /dev.
and with specified flags.

.br

Expand Down
4 changes: 2 additions & 2 deletions lgpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For more information, please refer to <http://unlicense.org/>
#include <pthread.h>
#include <linux/gpio.h>

#define LGPIO_VERSION 0x00010001
#define LGPIO_VERSION 0x00010700

#define LG_CD "LG_CD" /* configuration directory */
#define LG_WD "LG_WD" /* working directory */
Expand Down Expand Up @@ -2057,7 +2057,7 @@ D*/
int lgSerialOpen(const char *serDev, int serBaud, int serFlags);
/*D
This function opens a serial device at a specified baud rate
and with specified flags. The device must be present in /dev.
and with specified flags.
. .
serDev: the serial device to open
Expand Down
2 changes: 1 addition & 1 deletion rgpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For more information, please refer to <http://unlicense.org/>

#include "lgpio.h"

#define RGPIO_VERSION 0x00010200
#define RGPIO_VERSION 0x00010700

/*TEXT
Expand Down
18 changes: 10 additions & 8 deletions rgpiod.1
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ script commands.

.SH [serial]
Each entry in this section takes the form \fBuser=device\fP where
\fBdevice\fP indicates a serial device. E.g. \fBserial0\fP refers to
\fBdevice\fP indicates a serial device. E.g. \fB/dev/serial0\fP refers to
Linux device \fB/dev/serial0\fP

.br
Expand All @@ -660,13 +660,15 @@ characters) or \fB?\fP (matches a single character).
.br

.EX
fred=serial0 # user fred can access /dev/serial0.
fred=/dev/serial0 # user fred can access /dev/serial0.
.br
peter=tty* # user peter can access /dev/tty*.
peter=/dev/tty* # user peter can access /dev/tty*.
.br
boss=* # user boss can access /dev/*.
boss=/dev/* # user boss can access /dev/*.
.br
sally=serial?:ttyS* # user sally can access /dev/serial? and /dev/ttyS*.
sally=/dev/serial?:/dev/ttyS* # user sally can access /dev/serial?
.br
# and /dev/ttyS*.
.br
.EE
Expand Down Expand Up @@ -811,11 +813,11 @@ test3=y
.br
[serial]
.br
test1=serial*:ttyUSB*:ttyS*
test1=/dev/serial*:/dev/ttyUSB*:/dev/ttyS*
.br
test2=ttyUSB1:tty0:ttyS0
test2=/dev/ttyUSB1:/dev/tty0:/dev/ttyS0
.br
test3=null
test3=/dev/null
.br
.br
Expand Down
2 changes: 1 addition & 1 deletion rgpiod.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For more information, please refer to <http://unlicense.org/>

#include "lgCmd.h"

#define RGPIOD_VERSION 0x00010100
#define RGPIOD_VERSION 0x00010700

#define LG_ENVADDR "LG_ADDR"
#define LG_ENVPORT "LG_PORT"
Expand Down
15 changes: 7 additions & 8 deletions rgs.1
Original file line number Diff line number Diff line change
Expand Up @@ -2593,13 +2593,13 @@ The baud rate must be one of 50, 75, 110, 134, 150,
.br

.EX
$ rgs sero ttyAMA0 9600 0
$ rgs sero /dev/ttyAMA0 9600 0
.br
0
.br
.br
$ rgs sero tty1 38400 0
$ rgs sero /dev/tty1 38400 0
.br
1
.br
Expand Down Expand Up @@ -3386,19 +3386,18 @@ The number of PWM pulses to generate. A value of 0 means infinite.
.br

.IP "\fBdev\fP: a tty serial device" 0
The command expects the name of a serial device without the
leading /dev, e.g.
The command expects the name of a serial device, e.g.

.br

.EX
ttyAMA0
/dev/ttyAMA0
.br
ttyUSB0
/dev/ttyUSB0
.br
tty0
/dev/tty0
.br
serial0
/dev/serial0
.br
.EE
Expand Down
2 changes: 1 addition & 1 deletion rgs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This program provides a socket interface to some of
the commands available from lg.
*/

#define RGS_VERSION 0x00010200
#define RGS_VERSION 0x00010700

#define RGS_CONNECT_ERR 255
#define RGS_OPTION_ERR 254
Expand Down
File renamed without changes.

0 comments on commit 8f385c9

Please sign in to comment.