read via Javascript from SBC4

Supporting Browser-based Javascript and Node.js
Post Reply
mindthegap
Fresh meat
Posts: 4
Joined: Mon Sep 11, 2017 6:46 am
Contact:

read via Javascript from SBC4

Post by mindthegap »

I'm trying to read a MUJIE ENC4124_0 via quadrature encode and SBC4.

This is the first time I've used the SBC4. In the control panel I can see the data on port 1 after I updated everything.

Now I would like to run it via a local server using JavaScript.

I wanted to read the encoder data via the network server and the local adress. I downloaded the encoder example, but it says no phidget available. How do I go about reading the SBC4 over the internet via a local network server, how do I set this up, or how can I read the data directly from the SBC4.

Even if I connect directly to the SBC, there is no websocket:

Code: Select all

async function runExample() {
const conn = new phidget22.NetworkConnection(5661, '192.168.1.105');

try {
 await conn.connect();
 } catch (err) {
 console.error('Error during connect', err);
 process.exit(1);
 }

 const digitalOutput0 = new phidget22.DigitalOutput();

 try {
 await digitalOutput0.open(5000);
 } catch (err) {
 console.error('Error during open', err);
 process.exit(1);
 }

 try {
 await digitalOutput0.setDutyCycle(1);
 } catch (err) {
 console.error('Error during setDutyCycle', err);
 process.exit(1);
 }

 setTimeout(async () => {
 await digitalOutput0.close();
 conn.close();
 conn.delete();
 }, 5000);
}

runExample();
And is there a basic component of a Phidget for Vue3.
Attachments
phidget-configuarion-sbc4.jpg
(329.92 KiB) Not downloaded yet
User avatar
Patrick
Lead Developer
Posts: 656
Joined: Mon Jun 20, 2005 8:46 am
Location: Calgary
Contact:

Re: read via Javascript from SBC4

Post by Patrick »

If you're running this code in browser, you need to use the websocket port 8080. If you're running in Node.js, you use 5661.

-Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests