1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/minimal-examples/raw/minimal-raw-serial
Andy Green 286cf4357a sul: multiple timer domains
Adapt the pt sul owner list to be an array, and define two different lists,
one that acts like before and is the default for existing users, and another
that has the ability to cooperate with systemwide suspend to restrict the
interval spent suspended so that it will wake in time for the earliest
thing on this wake-suspend sul list.

Clean the api a bit and add lws_sul_cancel() that only needs the sul as the
argument.

Add a flag for client creation info to indicate that this client connection
is important enough that, eg, validity checking it to detect silently dead
connections should go on the wake-suspend sul list.  That flag is exposed in
secure streams policy so it can be added to a streamtype with
"swake_validity": true

Deprecate out the old vhost timer stuff that predates sul.  Add a flag
LWS_WITH_DEPRECATED_THINGS in cmake so users can get it back temporarily
before it will be removed in a v4.2.

Adapt all remaining in-tree users of it to use explicit suls.
2020-06-02 08:37:10 +01:00
..
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
minimal-raw-file.c sul: multiple timer domains 2020-06-02 08:37:10 +01:00
README.md minimal-raw-serial 2019-12-09 14:48:54 +00:00

lws minimal raw serial example

This demonstrates adopting a file descriptor representing a serial device into the event loop, printing a string on it every couple of seconds and showing any serial that is received.

The serial terminal is configured for 115200 8N1.

 $ ./lws-minimal-raw-serial <tty, eg, /dev/ttyUSB0>

build

 $ cmake . && make

usage

[2019/12/08 16:30:53:4436] U: LWS minimal raw serial
[2019/12/08 16:30:53:5016] E: callback_ntpc: set up system ops for set_clock
[2019/12/08 16:30:54:8061] N: callback_ntpc: Unix time: 1575822654
[2019/12/08 16:30:54:8253] N: LWS_CALLBACK_RAW_ADOPT_FILE
[2019/12/08 16:30:54:8364] N: callback_ntpc: LWS_CALLBACK_RAW_CLOSE
[2019/12/08 16:30:54:8456] N: LWS_CALLBACK_RAW_WRITEABLE_FILE
[2019/12/08 16:30:56:8455] N: LWS_CALLBACK_RAW_WRITEABLE_FILE
[2019/12/08 16:30:58:8460] N: LWS_CALLBACK_RAW_WRITEABLE_FILE
[2019/12/08 16:30:59:1570] N: LWS_CALLBACK_RAW_RX_FILE
[2019/12/08 16:30:59:1604] N: 
[2019/12/08 16:30:59:1641] N: 0000: 62                                                 b               
[2019/12/08 16:30:59:1644] N: 
[2019/12/08 16:31:00:8463] N: LWS_CALLBACK_RAW_WRITEABLE_FILE
[2019/12/08 16:31:01:6392] N: LWS_CALLBACK_RAW_RX_FILE
[2019/12/08 16:31:01:6397] N: 
[2019/12/08 16:31:01:6407] N: 0000: 65                                                 e               
[2019/12/08 16:31:01:6411] N: 
[2019/12/08 16:31:02:8463] N: LWS_CALLBACK_RAW_WRITEABLE_FILE
...                                               .               

The remote serial connection will show the string sent every 2s.