tom-2015 / rpi-ws2812-server

Raspberry Pi WS2812 (web) server tool
172 stars 39 forks source link

How to use the `-tcp` mode? #36

Open leoheck opened 4 years ago

leoheck commented 4 years ago

First of all, the README.md shows image

The command has the port missing, it should be like

sudo ./ws2812svr -tcp [PORT]

Also How could I use the -tcp mode with the command line.

I am trying this:

# Launch the server
sudo ./ws2812svr -tcp 12346

# Send some commands
echo "setup 0,8,3; init; fill 1,FFFFFF; render" | nc  127.0.0.1 12346

It gives me

Client connected.
Invalid channel number, use channels <number> to initialize total channels you want to use.
Gpio 0 is illegal for LED channel 0
ws2811_init failed: Selected GPIO not possible
Invalid channel number, did you call setup and init?

And the server closes, which is not good because someone can send some wrong command to just close the server.

Trying to send the same command from the README, like

echo "setup channel_1_count=8;rainbow;brightness 1,100;" | nc -k 127.0.0.1 9999

image

leoheck commented 4 years ago

Actually I made it work with this command (the README.md lacks the init and the render commands.

echo "setup 1,8,3;init;rainbow;brightness 1,100;render;" | nc 127.0.0.1 9998

leoheck commented 4 years ago

Here, the example for a loop, that disconnects the client after sending the command. It is working

read -r -d '' cmd <<-EOM
setup 1,8,3
init
rainbow
thread_start
do
    rotate 1,1,2
    render
    delay 200
loop
thread_stop
EOM

echo -e "$cmd" | nc -w 0 127.0.0.1 9998
leoheck commented 4 years ago

TCP version works better than using file or uname pipe. Thanks for referring me that.

tom-2015 commented 4 years ago

you're right the documentation was not up to date. I've updated that now also added 2 new effects: chaser and color_change.

leoheck commented 4 years ago

This is still wrong sudo ./ws2812svr -tcp

It should be like this unless you added a default port in the code. sudo ./ws2812svr -tcp [PORT]

tom-2015 commented 4 years ago

yes default port is 9999