1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/raw/minimal-raw-serial
Andy Green c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
..
CMakeLists.txt cmake: latest cmake shows dep warnings for scripts < 2.8.12 2020-12-06 19:44:54 +00:00
minimal-raw-file.c type comparisons: fixes 2021-01-05 10:56:38 +00: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.