Giter Club home page Giter Club logo

community-sdk's Introduction

Kano Community SDK

Check the wiki for more information!

What are the SDK available?

What is an SDK?

From Wikipedia, the free encyclopedia:

A software development kit (SDK or devkit) is typically a set of software development tools that allows the creation of applications for a certain software package, software framework, hardware platform, computer system, video game console, operating system, or similar development platform.

What is the Community SDK?

The community SDK are scripts, tools and libraries to help you to interact with your Kano Devices with your favourite programming language and on your choice of code editor. They are developed to be easy to understand and use in first place.

What are those SDKs for?

The goal is to provide a transition as smooth as possible between the block based experience from Kano Code to a text based programming that might feel a bit more "real".

But it's also a great way integrate your Kano devices with other devices, apps, the Internet of things and beyond.

If you are looking for a "production" ready SDK you will be better of with our Hardware SDK (coming soon).

Do you have a problem or a suggestion to make?

Please, tell us about it!

community-sdk's People

Contributors

murilopolese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

community-sdk's Issues

Filter connected devices by its type

Instead of filtering out all the available/connected devices every time it would be good to have a method that returns all the devices of a specific type and get the first available device from a type.

Something like:

// List all available motion sensors
DeviceManager.listMotionSensors()
.then((devices) => {
  console.log(devices.lenght, 'motion sensors were found')
});
// Get first available motion sensor
DeviceManager.getMotionSensor()
.then((msk) => {
  console.log('motion sensor found');
});
# List all available motion sensors
devices = list_motion_sensors()
#  Get first available motion sensor
msk = get_motion_sensor()

Pixel Kit Physical settings?

Trying to connect to the Pixel kit and use the example_list_connected_devices.py script. The script is functioning properly, but is unable to detect the Pixel kit itself.

Found 0 devices Found 0 Motion Sensor Kits Found 0 Pixel Kits

I'm assuming that there's some physical settings on the device that must be set to expose it for control from the serial port properly but I've been unable to find them.

If anyone's got the cheat sheet please post.

  • Yes - I've forked the WIKI and will document and submit PR when I figure this out. :)

Hardware SDK (coming soon).

Hey team. How's it going?
Just wondering it was a while ago - Hardware SDK (coming soon).
Do you happen to know when?
Cheers.

Method to close connection

Both MotionSensorKit and RetailPixelKit have a connect() method but no close() or disconnect() which makes the applications hang until keyboard interrupt.

Serial port doesn't close cleanly

Keyboard interrupt (and similar program exits, eg. sys.exit()) don't close the port connection, so leave terminals (windows) in limbo.
(Currently working round by changing approach to make serialdevice compatible with 'with' command (Can submit a pull request) but it then requires an explict while loop)

Python - Export to Pixel Kit

Is there anyway to export our Python code to the Pixel Kit instead of having to run it from our computer every time? If this is not possible with Python, can this be accomplished with the Javascript version? I saw #13 but didn't find it super clear.

Thanks in advance.

Windows 10 Driver for Pixel kit

Trying to connect Pixel kit to Window 10 machine. Device Manager shows the Pixel kit as FT231X USB UART for which there are no drivers available. Doing a little digging, it appears I should be installign drivers for the Ftdi chip from here.
https://www.ftdichip.com/Drivers/VCP.htm

Can anyone confirm if this is accurate or if there's another method I should be using for loading the drivers?
[update] I was able to successfully install the drivers above and Windows 10 now sees the device as a "USB Serial Converter"

thanks!

python library: get_x functions on PIxel object not working

Environment:
macOS Mojave
Python version

sys.version
'3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]'

Having issues with pixel python code status methods on pixel class object. In the example below you can see that I have an object of <class 'communitysdk.retailpixelkit.RetailPixelKitSerial'> that is in a connected state. I used the connect_to_wifi method to ensure that it was connected and response suggests that it worked as I'm getting a valid IP address for this network.

When I run the .get_wifi_status method on this object. I get the error below. This is consistent with the get_battery function as well.

my_pixel.connect()
my_pixel.is_connected
True
my_pixel.connect_to_wifi("my_network", "my_secret")
{'ssid': 'my_network', 'mac_address': '30AEA40D8858', 'connected': True, 'signal_strenth': -82, 'ip': '10.101.0.142', 'netmask': '255.255.255.0', 'gateway': '10.101.0.1'}
list_connected_devices()
[<communitysdk.retailpixelkit.RetailPixelKitSerial object at 0x10546db38>]
my_pixel.get_wifi_status()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/retailpixelkit.py", line 52, in get_wifi_status
    return self.rpc_request('wifi-status', [])
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/rpcclient.py", line 76, in rpc_request
    self.loop.run_until_complete(tasks)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/rpcclient.py", line 53, in wait_for_response
    raise TimeoutError('Request timed out')
TimeoutError: Request timed out

The get_battery_status method also appears to be having issues, but with slightly different output.

my_pixel.get_battery_status()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/retailpixelkit.py", line 49, in get_battery_status
    return self.rpc_request('battery-status', [])
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/rpcclient.py", line 76, in rpc_request
    self.loop.run_until_complete(tasks)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/rpcclient.py", line 53, in wait_for_response
    raise TimeoutError('Request timed out')
TimeoutError: Request timed out
Future exception was never retrieved
future: <Future finished exception=SerialException('read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)',)>
Traceback (most recent call last):
  File "/Users/christopheryoung/VENVpyawair/lib/python3.6/site-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/christopheryoung/PycharmProjects/community-sdk/communitysdk/serialdevice.py", line 45, in poll_data
    msg = self.connection.readline()
  File "/Users/christopheryoung/VENVpyawair/lib/python3.6/site-packages/serial/serialposix.py", line 509, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

[Suggestion] Use platform & language neutral server/client bidirectional architecture

@murilopolese - looking at your other 2 issues here and there.
You're running into the complication of programming specific issues -- like dealing with Python thread
out of main function, and direct port of NodeJS / Python websocket implementation on language level.

Here's my suggestion to use a platform-neutral and programming language-neutral solution:

  • gRPC is a platform-neutral and programming language-neutral mechanism;
  • gRPC communication, using definition file, we can generate both server/client language specific library;
  • it can be much faster than http/2 with JSON, some benchmark from etcd;
  • you're already using RPC;

Rather than giving you a solution on your issues, I have created a simple Proof of Concept to demonstrate how this can work and potentially eliminate a lot of similar issues you might have in future.

Let's dicuss :-)

Can't call `rpc_request` from event callbacks

Can't get event loop from inside a coroutine, apparently. I have no idea how to fix this and it's probably because I should be doing this in a different way.

This code:

from communitysdk import list_connected_devices, MotionSensorKit
msk = None
devices = list_connected_devices()
if len(devices):
    if isinstance(devices[0], MotionSensorKit):
        msk = devices[0]
        def on_proximity(p):
            if p > 200:
                try:
                    msk.set_mode('proximity')
                except Exception as e:
                    print(e)
            else:
                print('proximity', p)
        def on_gesture(g):
            if g == 'up':
                try:
                    msk.set_mode('proximity')
                except Exception as e:
                    print(e)
            else:
                print('gesture', g)
        msk.on_proximity = on_proximity
        msk.on_gesture = on_gesture
else:
    print('there is no device connected')

Prints There is no current event loop in thread 'ThreadPoolExecutor-0_0'. when I swipe up on Motion Sensor.

C# support?

I am fairly fluent in unity C#, and i'd like to see what i could make with the motion sensor.

(edit: i hope this is the right place to put this? sorry if it isnt)

Connect to PixelKit over Websocket

RIght now only a RetailPixelKitSerial is implemented but the Pixel Kit offers the same RPC protocol over websocket. The Nodejs SDK has it implemented already but the Python SDK still lacks it.

Kickstarter

Hi,
I'm trying to send some javascript code to the kickstarter pixel kit.
Ideally I'd like to send code like this:

global.when('start', function () {
  devices.get('lightboard').turnOn({
    type: 'single',
    x: 1 - 1,
    y: 1 - 1
  }, '#4CAF50');
}); 

When I export the "app" from the desktop application I get a .kcode file which is a json file. In this file I can see ".code.snapshot.javascript". If I change that content and import again nothing works... Is there a way I can auto generate the block part from the javascript I just generated? Or simply just push the javascript code?

Thanks,
Daniel

Harry Potter coding kit

Hi,

I would like to know you you have any code available to exploit the wand.
The idea is to use the wand as main interface to interact with different object controlled by a Raspberry like light or motors for exemple.

Did you have any code available or did you plan to give some access ?

Best regards,
Florian Meyer

can't find module communitysdk

I'm using the mu editor, trying to run a one of the routines in the sdk. I keep getting a "no module communitysdk" message. Where should I put the sdk relative to the mu editor's directories?

Kano LED Lightshow OS v2.1.0

Hi, are the specs or any of the code for the original Kickstarter "Powerup Kit" available?

I'm happy I can still download the OS, but I'm curious about hacking on the board. I took my old Pi 1 and made it into a Pi-Hole, and it'd be neat if I could plugin in the LED board and have it light up as ads get blocked.

Thanks!

Python module and package naming

Currently the Python SDK isn't packaged in a way that allows it to be imported as a module. I am very happy to help with this but there are a few issues, most important (at the moment) the name!

As I know already, @malminhas was excited to see a library with an import kano or from kano import motionsensorkit) etc. I think that's exciting and it would make sense from a user perspective.

To achieve this, it would mean that the base folder name communitysdk should be renamed to kano. I don't believe that would interefere in any way with the KANO OS (in my knowledge the only place where a similar Python KANO library exists) as:

  • The target group is completely different. No user of the KANO OS, would experiment with our libraries as they are very closed and specific
  • The current libraries don't support Python 3 (Only <= Python 2.7)

If people agree on that, I can offer the PR fixing the issue, by creating a Python Package following the Packaging Guide (which can easily be converted in a future Native Debian Package that would be able to be included in the main Debian OS as well, and so to reach literally everybody who owns a Debian (and Debian-based including Ubuntu, Kali, PureOS, Raspbian).

What people think? @murilopolese @malminhas @russormes

yarn install error

the error
make: Leaving directory '/home/pi/pixlekit/community-sdk-0.1.0-nodejs/node_modules/serialport/build' gyp ERR! build error gyp ERR! stack Error:makefailed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23) gyp ERR! stack at ChildProcess.emit (events.js:314:20) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) gyp ERR! System Linux 4.19.118-v7+ gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/pi/pixlekit/community-sdk-0.1.0-nodejs/node_modules/serialport gyp ERR! node -v v14.8.0 gyp ERR! node-gyp -v v5.1.0 gyp ERR! not ok info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

LED color codes.

I got "example_pixel_kit_stream_frame.py" running. It would be helpful to know what the six digit hex codes are for the possible colors of the leds.

Another yarn install error

Hi there. I have up-to-date versions of node and yarn. However, when I navigate into the sdk folder in powershell and run yarn install , It returns:

error C:\Users\jeffy\projects\kano\node_modules\serialport: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments:
Directory: C:\Users\jeffy\projects\kano\node_modules\serialport
Output:
prebuild-install WARN install No prebuilt binaries found (target=14.17.1 runtime=node arch=x64 platform=win32)

C:\Users\jeffy\projects\kano\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.9.9 found at "C:\Users\jeffy\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:326:5)
gyp ERR! stack at ChildProcess.emit (events.js:375:28)
gyp ERR! stack at maybeClose (internal/child_process.js:1055:16)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\jeffy\projects\kano\node_modules\serialport
gyp ERR! node -v v14.17.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

Setting colors for individual LEDs on Pixel Kit

In both implementations for "streaming frame" (python and nodejs), what the communitysdk does is to encode and send a list of 128 color values: One for each LED.

This list is a one dimensional representation of a two dimensional matrix of LEDs so to set the color of an LED by the x and y coordinate we need to convert a pair of coordinates (x, y) into an index in the unidimensional list.

The math is not complicated, for example if you want to set this color to red (#ff0000) all you have to do is to set a value in the frame array:

index = (x * 16) + y
frame[index] = '#ff0000'
# stream frame here

It would be great to have a method inside the communitysdk to solve this issue and/or an example on how to do this calculation.

community-SDK node.js methods

Hey.
Does someone help with methods?
While Kanno motion sensor desktop app, you have an access to methods that manipulate DOM, or at least have an access to events (for example setting canvas background, etc.).
Are those available with community-sdk?
At The moment we can print in node.js console proximity status and gesture. I was not able to access any of methods available while running Kano desktop app for proximity sensor through local development using provided example code. Could you please help.
Thank you in advance.

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.