1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

#84: custom baudrate support for OpenBsd, and Dragonfly (but not NetBsd)

This commit is contained in:
Joe Merten
2018-01-15 23:30:30 +01:00
parent 249cf8ea3c
commit 6ebb8c56fc
4 changed files with 26 additions and 5 deletions

View File

@ -38,7 +38,8 @@ OBJS += linenoise-1.0/linenoise.o
linenoise-1.0/linenoise.o : linenoise-1.0/linenoise.c linenoise-1.0/linenoise.h
## Comment this in to enable custom baudrate support.
## Works with: Linux (kernels > 2.6), FreeBSD, macOS (Tiger and above)
## Works with: Linux (kernels > 2.6), FreeBSD, OpenBSD, DragonFly,
## macOS (Tiger and above)
#CPPFLAGS += -DUSE_CUSTOM_BAUD
## Comment this IN to remove help strings (saves ~ 4-6 Kb).

16
bsd.txt
View File

@ -56,9 +56,20 @@ So I changed that `#define USE_IOCTL` appropriate.
But however, there are some issues regarding rts and dtr control for OpenBsd, NetBsd and Dragonfly (see details below).
Custom Baudrates
================
Tested with 80000 baud.
Most Bsd variants (except NetBsd) worked well with Ftdi, but not with Prolific adapter (see details below).
Linux and OSX / macOS still work with both adapters.
Issues
======
FreeBsd
-------
- Custom Baudrates work well with Ftdi adapter. But with Prolific adapter, baudrate switched silently to 9600 baud.
OpenBsd
-------
- `term_get_mctl()` sometimes reports wrong values for rts and dtr state (after port open).
@ -66,11 +77,15 @@ OpenBsd
Same for interactive toggle via `[C-t]` and `[C-g]`. Toggle rts via `[C-g]` works but toggle
dtr via `[C-t]` also changes the state of rts (and `term_get_mctl()` reports wrong rts state afterwards).
- Issues occurs with both Ftdi and Prolific adapters.
- Custom baudrates with Prolific adapter has the same issue as in FreeBsd.
NetBsd
------
- `term_get_mctl()` sometimes reports wrong values for rts and dtr state (after port open)
- Issue occurs with both Ftdi and Prolific adapters.
- Seems that there is no support for custom baudrates.
- With Ftdi adapter: "Cannot set the device attributes: Invalid argument".
- With Prolific adapter no error message but same behaviour as in FreeBsd.
Dragonfly
---------
@ -78,4 +93,5 @@ Dragonfly
Need to pass `--nolock` or build with `#define USE_FLOCK` not set.
- `term_get_mctl()` sometimes reports wrong state for dtr, e.g. when passing `--lower-dtr`.
- When exit via `[C+x]`, got "term_exitfunc: reset failed for dev /dev/ttyU0: Invalid argument".
- Custom baudrates with Prolific adapter has the same issue as in FreeBsd.

View File

@ -29,9 +29,10 @@
#define CUSTBAUD_BSD_H
/* Note that this code might also work other BSD variants, but I have only
* tested with those listed below.
* tested with those listed below. Also tested __NetBSD__ but won't work.
*/
#if (defined (__FreeBSD__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
#if (defined (__FreeBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
#define HAS_CUSTOM_BAUD
@ -46,6 +47,9 @@
* available for term_baud_up()/down().
*
* FreeBSD 11.0 termios.h has 460k and 921k but misses e.g. 500k and >=1M.
* OpenBSD 6.2 termios.h is missing all >230k (like macOS).
* NetBSD 7.1.1 do same as FreeBSD 11.0.
* DragonFly 5.0.2 looks same as OpenBSD 6.2.
*/
#if defined(HIGH_BAUD)
@ -106,5 +110,5 @@ int tcsetattr_custom(int fd, int optional_actions, const struct termios *tiop);
/***************************************************************************/
#endif /* __FreeBSD__ || __APPLE__ && USE_CUSTOM_BAUD */
#endif /* __FreeBSD__ || __OpenBSD__ || ... || __APPLE__ && USE_CUSTOM_BAUD */
#endif /* CUSTBAUD_BSD_H */

2
term.c
View File

@ -70,7 +70,7 @@
#endif
#endif
#if (defined (__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
#if (defined (__FreeBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
/* only for some BSD and macOS (Tiger and above) */
#include "custbaud_bsd.h"