mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Merge branch 'JoeMerten-bsd-improvements'
This commit is contained in:
3
Makefile
3
Makefile
@ -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).
|
||||
|
98
bsd_notes.txt
Normal file
98
bsd_notes.txt
Normal file
@ -0,0 +1,98 @@
|
||||
Test environment
|
||||
================
|
||||
|
||||
- VirtualBox host Kubuntu 16.04
|
||||
- FreeBsd 11.0 (VM)
|
||||
- OpenBsd 6.2 (VM)
|
||||
- NetBsd 7.1.1 (VM)
|
||||
- Dragonfly 5.0.2 (VM)
|
||||
- OSX 10.11.6 El Capitan (native on Macbook Pro)
|
||||
- macOS 10.12 Sierra (native on Macbook Pro)
|
||||
- Kubuntu 16.04 (native on Macbook Pro)
|
||||
- all above on Intel x86 64 Bit
|
||||
- Cygwin 5.1 on Windows XP 32 Bit host
|
||||
- Ftdi FT232R, max 1MBaud (chip can 3MBaud, but hw rs232 level shifter is specified for just 1MBaud)
|
||||
- Prolific PL2303, max 230kBaud (chip can 12MBaud, but hw rs232 level shifter is specified for just 230kBaud)
|
||||
- Unknown Asus onboard (16550 compatible?) uart chip, max 115kBaud.
|
||||
Just minor testing with this uart, because it seems that it don't supports non standard baudrates.
|
||||
|
||||
For Cygwin, I'd just checked if it will build and ran `picocom -h`. I'd personally failed opening a serial port within Cygwin.
|
||||
Note that for Cygwin it needs to implement a `cfmakeraw()` replacement. See also:
|
||||
https://cygwin.com/ml/cygwin/2008-09/msg00295.html
|
||||
https://sourceforge.net/p/ser2net/patches/9/
|
||||
https://sourceforge.net/p/ser2net/patches/_discuss/thread/8b87fdad/ed37/attachment/ser2net-2.2-cygwin.patch
|
||||
|
||||
|
||||
Accessing serial ports (examples)
|
||||
=================================
|
||||
|
||||
- Kubuntu:
|
||||
/dev/ttyS0
|
||||
/dev/ttyUSB0
|
||||
|
||||
- FreeBsd:
|
||||
/dev/ttyu0
|
||||
/dev/ttyU0
|
||||
|
||||
- OpenBsd:
|
||||
/dev/cuaU0
|
||||
|
||||
- NetBsd:
|
||||
/dev/ttyU0
|
||||
|
||||
- Dragonfly:
|
||||
/dev/ttyU0
|
||||
|
||||
- macOS
|
||||
/dev/tty.usbserial-FTGNI4B7 (Ftdi)
|
||||
/dev/tty.usbserial (Prolific)
|
||||
|
||||
|
||||
Manual controlling handshake lines
|
||||
==================================
|
||||
|
||||
All above listed Bsd variants (FreeBsd, OpenBsd, NetBsd, Dragonfly and even macOS) fail when trying to control the handshake lines
|
||||
(rts and dtr) using the `tcsetattr()` based default implementation. But they all basically work with the `ioctl()` based alternate code.
|
||||
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).
|
||||
- `--lower-rts` works as expected, but `--lower-dtr` lowers both rts and dtr lines.
|
||||
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
|
||||
---------
|
||||
- Got "FATAL: cannot lock /dev/ttyU0: Operation not supported" on startup.
|
||||
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.
|
||||
|
@ -38,10 +38,11 @@
|
||||
* - Have not tested with more recent macOS or Ftdi driver until now.
|
||||
*/
|
||||
|
||||
/* Note that this code might also work with OpenBSD, NetBSD et cetera, but I have not tested.
|
||||
* That's why I only check for `defined (__FreeBSD__)` here.
|
||||
*/
|
||||
#if (defined (__FreeBSD__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
|
||||
/* Note that this code might also work with other BSD variants, but I have only
|
||||
* tested with those listed below. Also tested __NetBSD__ but won't work. */
|
||||
#if (defined (__FreeBSD__) || defined (__OpenBSD__) || \
|
||||
defined (__DragonFly__) || defined (__APPLE__)) && \
|
||||
defined (USE_CUSTOM_BAUD)
|
||||
|
||||
#include "custbaud_bsd.h"
|
||||
#include <string.h>
|
||||
@ -54,9 +55,10 @@
|
||||
#include "term.h"
|
||||
|
||||
/***************************************************************************/
|
||||
/* As we can see in FreeBSD and macOS termios.h all the baudrate constants are transparent,
|
||||
* like B115200=115200. There is no need for any integer <-> code translation.
|
||||
* So we can pass any baudrate we want directly to / from cfsetospeed() & co.
|
||||
/* As we can see in BSD and macOS termios.h all the baudrate constants are
|
||||
* transparent, like B115200=115200. There is no need for any integer <-> code
|
||||
* translation. So we can pass any baudrate we want directly to / from
|
||||
* cfsetospeed() & co.
|
||||
*/
|
||||
int cfsetospeed_custom(struct termios *tiop, int speed) {
|
||||
return cfsetospeed(tiop, speed);
|
||||
@ -142,4 +144,4 @@ int tcsetattr_custom(int fd, int optional_actions, const struct termios *tiop) {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif /* FreeBSD || __APPLE__ && USE_CUSTOM_BAUD */
|
||||
#endif /* __FreeBSD__ || ... || __APPLE__ && USE_CUSTOM_BAUD */
|
||||
|
@ -36,7 +36,10 @@
|
||||
* tcsetattr_custom()), we want to provide the values here to have them
|
||||
* available for term_baud_up()/down().
|
||||
*
|
||||
* FreeBSD termios.h has 460k and 921k but misses e.g. 500k and >=1M.
|
||||
* 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)
|
||||
|
@ -96,7 +96,8 @@ here.
|
||||
|
||||
: Toggle the RTS line. If RTS is up, then lower it. If it is down,
|
||||
then raise it. Not supported if the flow control mode is RTS/CTS.
|
||||
Only supported in Linux, FreeBSD and macOS.
|
||||
Only supported in Linux, FreeBSD, OpenBSD, NetBSD, DragonFly and
|
||||
macOS.
|
||||
|
||||
**C-backslash**
|
||||
|
||||
|
@ -255,8 +255,8 @@ int sig_exit = 0;
|
||||
int tty_fd = -1;
|
||||
int log_fd = -1;
|
||||
|
||||
/* RTS and DTR are usually raised upon opening the serial port (at
|
||||
least as tested on Linux and macOS, but FreeBSD behave different) */
|
||||
/* RTS and DTR are usually raised upon opening the serial port (at least
|
||||
as tested on Linux, OpenBSD and macOS, but FreeBSD behave different) */
|
||||
int rts_up = 1;
|
||||
int dtr_up = 1;
|
||||
|
||||
|
23
term.c
23
term.c
@ -52,23 +52,32 @@
|
||||
#define CMSPAR 0
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD__) || defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__) || defined(__DragonFly__) || \
|
||||
defined(__APPLE__)
|
||||
#define USE_IOCTL
|
||||
#endif
|
||||
#ifdef USE_IOCTL
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(USE_CUSTOM_BAUD)
|
||||
|
||||
#ifdef USE_CUSTOM_BAUD
|
||||
#if defined (__linux__)
|
||||
/* only works for linux, recent kernels */
|
||||
#include "termios2.h"
|
||||
#endif
|
||||
|
||||
#if (defined (__FreeBSD__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
|
||||
/* only for FreeBSD and macOS (Tiger and above) */
|
||||
#elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
|
||||
defined (__DragonFly__) || defined (__APPLE__)
|
||||
/* only for some BSD and macOS (Tiger and above)
|
||||
* Note that this code might also work other BSD variants, but I have only
|
||||
* tested with those listed below. Also tested __NetBSD__ but won't work. */
|
||||
#include "custbaud_bsd.h"
|
||||
#else
|
||||
#error "USE_CUSTOM_BAUD not supported in this system"
|
||||
#endif
|
||||
#endif /* of USE_CUSTOM_BAUD */
|
||||
|
||||
|
||||
/* Time to wait for UART to clear after a drain (in usec). */
|
||||
#define DRAIN_DELAY 200000
|
||||
|
Reference in New Issue
Block a user