i use servoblaster, one of the first projects for PWM (pulse with modulation) on the raspberry pi. Now i got a new raspberry and i wanted to try the very promising pigpio. It looks really fast and properly done.
But i also want to be able to control everything over a simple html website which is driven by websockets, also a fast way to communicate between modern devices. websockets is supported on all new phones. When the connection is open, you start to send, in a bidirectional way, pure data! This makes it my favorite api to communicate with other devices/servers.
To communicate with servoblaster, nodejs needs to write the data somewhere.
servoblaster uses DMA (direct memory access). This allows you to not destroy your memorycard :), probably the fastest way to store information.
That stream location is
/dev/servoblaster. In the Linux console you write
echo 0=50% > /dev/servoblaster
this sets the GPIO-4 (which is 0 for the servoblaster) to 50% of the duty cycle. In nodejs probably the best and only way to continuosly write a stream is:
//WORKING var fs=require('fs'), stream=fs.createWriteStream('/dev/servoblaster'); stream.write('0=50%');
the above code works perfect with servoblaster.but does not work with the pigpio
i installed everything and tested various pigpio commands in the console. Everything works in the console with pigpio, in nodejs NO.
//NOT WORKING var fs=require('fs'), stream=fs.createWriteStream('/dev/pigpio'); stream.write('p 4 255'); // turn on GPIO-4 // after a while i also tested // stream.write('"p 4 255"');
the above code does not work.
Said that, i hope you can help me figure out how to directly write the websocket stream (from nodejs) to the /dev/pigpio
i changed also permissions to the /dev/pigpio but nothing.
Also if you know a better(i always only mean FASTER) way to directly write the needed data from websockets to the pigpio DMA location. i'm always rdy to learn new stuff.
the working raspberry has a headless armhf wheezy version that uses only about 40mb-50mb ram with everything up and running (servoblaster & various nodejs servers).
i try to not use other languages than js(nodejs) & c to keep the memory impact low and also try to run everything from the ram. this makes it incredible fast.
i hope i can also properly test the pigpio!