If I want to use scratch for my own Harware devices which has serialport on it ,How could I write a javascript extention that support it?
Actually I try to use npm install serialport ,and I write a .js file that opens a serialpor, But I can just run this file in node.js.
How could I add this to scratch-vm or scratch-gui?
If you want to try this , you can run :
sudo npm install -g serialport
write a file : serialport.js
const SerialPort = require('serialport')
Ubuntu 16.04 Google Chorm 71.0.3578.98
Thanks for your reply. I'm not farmilar with how to use your python files into Scratch3.0 .
@XueYuSky The document is here(chinese), I just replied to your mail :)
I chose to use node.js (serialport) and redirect the data received from the serial on a websocket connection. It works very well!
@cotestatnt Thanks a lot . At first,I also use node.js(serialport) and can read and write data on a serialport by standalone main.js. But the problem is I can't redirect the data received from the serial on a websocket connection. I am learning websocket and will update this method after I do that.
If you have good examples to show how to do this, welecom to post your method.
@XueYuSky , here you can find my actually implementation. Please take in mind, I'm not an expert programmer (especially with Javascript), I'm sure there's a better method!
For example, doing all the jobs in the same extension script 'index.js' so that it is not necessary to start the wsServer.js script manually.
@XueYuSky , here you can find my actually implementation. Please take in mind, I'm not an expert programmer (especially with Javascript), I'm sure there's a better method!
For example, doing all the jobs in the same extension script 'index.js' so that it is not necessary to start the wsServer.js script manually.
Thank you so much , I finally make it after I change some code from you. Because the hardware is not arduino. I designed it by myself with special protocol. Your answer really helped me!
I write a serial extension recently,it can open a serial port ,send messages,receive messages. But it still has some bugs to fix.
I write a serial extension recently,it can open a serial port ,send messages,receive messages. But it still has some bugs to fix.
Would you mind sharing the link please? Thanks in advance.