A year ago i have set up a OpenHabian server and send raw data over CUL with echo (commandline and script) was no problem. (to trigger a switch with unkonwn protocol)
Now i have setup a new server for testing and have no luck
The nanoCul work on the other Server also when i send the plain ascii chars over a windows terminal so the CUL is working.
I think there is something wrong in the openhabien config (sending permissions) but i dont find whats going wrong.
I can get the Version of the CUL … i can set it to monitor mode and recive data … but i cant send something.
The device ist set to chmod 777 so everyone should have the full access:
I dont know why it worked on the old server out of the box …
The Steps:
By default every serialport is only in canonical mode so i have to add raw and -echo mode (setting up the port):
stty -F /dev/ttyUSB0 38400 raw -echo
Open the port i have used cat in background mode:
cat /dev/ttyUSB0 &
Send the Echo:
echo G0030af13403b1610097ee8 > /dev/ttyUSB0
Kill the cat process
All this i can run automatic with the following setup:
A simple Rule bind to a switch or other item:
(Replace G0030ae143f3b1814097ee8 with the raw code you want to send)
when
Item test_sw2 received update ON
then
executeCommandLine("sh /etc/openhab2/scripts/sendtoculraw.sh G0030ae143f3b1814097ee8")
postUpdate(test_sw2, OFF)
end
And the sendtoculraw.sh script (change portpaths to your needs):
#!/bin/sh
# Set up the serialport
stty -F /dev/ttyUSB0 38400 raw -echo
# Open the serialport with cat in background mode
cat /dev/ttyUSB0 &
# Capture PID of cat process to terminate it when done
catPid=$!
# Wait 1.5 seconds so the serial port will be open when we send
sleep 1.5
# Echo the raw command
echo $1 > /dev/ttyUSB0
# Kill the cat process
kill $catPid
I think this is a realy cool solution to trigger or read Devices with an unknown protocol.
You can simply read the incoming raw signal from the unknown device lets say a remote control.
And then send out the raw signal over openhub to trigger the device