Giter Club home page Giter Club logo

Comments (5)

murilopolese avatar murilopolese commented on August 16, 2024

Hey, @dpkano!

If you are using the app to generate the code, perhaps the best idea would be to use the app to upload the code. Currently the SDK does not support the Kickstarter Pixel Kit but even if it does, it will probably not focus on uploading code generated from Kano Code App. Not because we don't want it to happen but because right now the idea is to have an independent API to draw on screen and get button events.

Your code would probably look more like this example of how to stream a frame to the Pixel Kit.

Having said that, there is an "RPC" method to upload animations to the Retail Pixel Kit and code (like yours) to the Kickstarter Pixel Kit. Those methods are not yet implemented by this SDK for technical reasons: They require way more configuration and a more complex approach then just sending a "frame" to the screen.

If you are up to interacting with the Kickstarter Pixel Kit with the communitysdk API I can try to add the Kickstarter vendor/product id to the device manager so it will list your Pixel Kit as a valid communitysdk device. If you want to give a quick try, you could try to connect to your device using the following lines:

// If your script is running from the root folder
const PixelKit = require('./src/retailpixelkit.js');

// First you need to find your Pixel Kit serial port. That changes depending of your OS.
let pk = new PixelKit({
  path: 'YOUR PIXEL KIT SERIAL PORT PATH HERE',
});

// Connect to your Pixel Kit, interact with it (check the examples) and handle errors
pk.connect()
  .then((connectedPixelKit) => {
    // Do stuff with your Pixel Kit here!
  })
  .catch((err) => console.log(err))

Let me know if you give it a try and what kind of errors and ideas you get!

from community-sdk.

dpkano avatar dpkano commented on August 16, 2024

Nice. I'll give it a try.
In addition to that I tapped the network communication between the app and the kit. Instead of using port 9998, I saw the port 3000 was being used. So I should that port here, right? So aside from the port, is the protocol in both types of devices (kickstarted and retail) the same?

Thanks,
Daniel

from community-sdk.

murilopolese avatar murilopolese commented on August 16, 2024

Oh nice! Well spotted!!!! 🎉 🥇

In addition to that I tapped the network communication between the app and the kit. Instead of using port 9998, I saw the port 3000 was being used. So I should that port here, right?

Yes, in case you want to connect via WebSocket to your Pixel Kit you should definitely change that port.

So aside from the port, is the protocol in both types of devices (kickstarted and retail) the same?

Yes, they both implement an RPC protocol. If you want more detail on how that works, this file is the implementation we are using.

If you send a JSON on a very specific format to the Pixel Kit (over WebSocket or USB Serial) it will respond with another JSON. That is also true for hardware events like button and joystick presses. Although both Pixel Kits are RPC servers, they have a few "methods" that are different. Unfortunately I don't have in hands a full specification of this API but if you sniff the packets Kano Code App sends you are definitely going to find them all!

from community-sdk.

dpkano avatar dpkano commented on August 16, 2024

Quick update:

  1. I tried the WS: I keep receiving ECONNRESET
  2. I tried to install the npm serial port dependency on windows... and I keep having errors.... like "Error: gyp failed with exit code: 1"... :(

I did not have time to fix these issues... maybe on the weekend... :(

from community-sdk.

murilopolese avatar murilopolese commented on August 16, 2024

Hey, @dpkano ! Thanks a lot for the update: You are a star 🌟!

The ECONNRESET might be something getting stuck on the Pixel Kit side. I hate when I have to say that, it feels like I'm dumbing down other people but unfortunately I have to do it: Have you tried to turn the Pixel Kit off and on again 🤣

This could be that the previous WebSocket connection wasn't closed properly so the Pixel Kit rejects any new connection before the previous one is closed. I have been fiddling around with WebSockets for a while now and I still don't have a good answer on how to gracefully close it but I hope one day we'll find it.

Now about the gyp failing... That is an old friend of mine...

I'm not sure how familiar you are with gyp but it is a tool to compiling native binaries on the user machine. For example: Nodejs doesn't have native support for serial communication so the nodeserialport module has some C++ code that gets compiled by your machine to do this job. The reason for that is every platform implements serial communication in a different way so compiling from C is a must. If you are lucky enough npm will find out that the module has "precompiled" versions and will automatically download it for you, without having to compile. If there are no "precompiled" binaries it will try to compile.

There is a list of things that could be wrong and perhaps it's worth to give a look at Installing SerialPort from their official documentation. It might be a nodejs, npm or node-gyp version problem. It could also be a matter of installing some dependencies on your computer (such as VisualStudio and the Windows SDK). It's hard to say but let me know how it goes and perhaps there is something on the code or docs I can update to help!

from community-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.