Coder Social home page Coder Social logo

lego-hub-tk's People

Contributors

smr99 avatar spudgunman avatar ws1088 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lego-hub-tk's Issues

Run fails with cannot import name 'IOBluetoothDeviceInquiry'

Hey! Could you assist please with installation, I keep getting these. Tried to reinstall everything I knew.

I'm from Java and quite newbie with python env

ego-hub-tk git:(main) ✗ python3 run_command.py
Traceback (most recent call last):
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/run_command.py", line 17, in <module>
    from comm.HubClient import ConnectionState, HubClient
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/HubClient.py", line 5, in <module>
    from comm.MultiplexedConnectionMonitor import MultiplexedConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/MultiplexedConnectionMonitor.py", line 2, in <module>
    from comm.BluetoothConnectionMonitor import BluetoothConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/BluetoothConnectionMonitor.py", line 4, in <module>
    import bluetooth
  File "/usr/local/lib/python3.9/site-packages/bluetooth/__init__.py", line 13, in <module>
    from bluetooth.macos import *
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/__init__.py", line 1, in <module>
    import bluetooth.macos.discovery as discovery
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/discovery.py", line 6, in <module>
    from Foundation import NSObject, IOBluetoothDeviceInquiry
ImportError: cannot import name 'IOBluetoothDeviceInquiry' from 'Foundation._context' (/usr/local/lib/python3.9/site-packages/Foundation/_context.py)
➜  lego-hub-tk git:(main) ✗

Establishing an upstream link between HUB and PC

Hello.

I am having trouble establishing an link for upstream/downstream data link. Could you please elaborate, perhaps with some examples, how to establish a 2-way data link between HUB <-> PC or is that something that is not possible with this tool?

The only option that I see, is possibility of activating different slots, but we can not call a function with variables passed down within a program, on a slot - am I correct?

Unhandled message 'm': 14

I was playing around with this today and got

WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 0}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 5}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 1}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 2}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 0}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 2}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 1}
WARNING:data.HubMonitor:unhandled message: {'m': 14, 'p': 0}

Any ideas?

ModuleNotFoundError: No module named 'bluetooth.linux'

First of all, thanks for your effort to allow programming the Lego Hub on Linux!

This is what happens when I run python3 run_command.py ls:

$ python3 run_command.py ls
Traceback (most recent call last):
  File "/home/ppalaga/orgs/python/lego-hub-tk/run_command.py", line 17, in <module>
    from comm.HubClient import ConnectionState, HubClient
  File "/home/ppalaga/orgs/python/lego-hub-tk/comm/HubClient.py", line 5, in <module>
    from comm.MultiplexedConnectionMonitor import MultiplexedConnectionMonitor
  File "/home/ppalaga/orgs/python/lego-hub-tk/comm/MultiplexedConnectionMonitor.py", line 2, in <module>
    from comm.BluetoothConnectionMonitor import BluetoothConnectionMonitor
  File "/home/ppalaga/orgs/python/lego-hub-tk/comm/BluetoothConnectionMonitor.py", line 4, in <module>
    import bluetooth
  File "/home/ppalaga/.local/lib/python3.9/site-packages/bluetooth/__init__.py", line 18, in <module>
    from bluetooth.linux import *
ModuleNotFoundError: No module named 'bluetooth.linux'

I have installed the prerequisites via pip3 install -r requirements.txt before running run_command.py ls.
I am quite new to Python and pip, maybe I am missing something basic.

I am on Fedora 34.

Could not open port, Access is denied.

Hello. On windows it may ask you permission for USB com's.

Configuration file does not exist: C:\Users\partsjoo\AppData\Local\lego-hub-tk\lego-hub-tk\lego_hub.yaml
2022-01-18 04:57:07,836 INFO App LEGO status app starting up
2022-01-18 04:57:08,054 INFO comm.ConnectionMonitor Starting USB autoconnect detection loop
2022-01-18 04:57:08,055 INFO comm.ConnectionMonitor Starting Bluetooth autoconnect detection loop
2022-01-18 04:57:08,055 WARNING comm.BluetoothConnectionMonitor Not scanning: no BlueTooth address configured
2022-01-18 04:57:08,055 INFO comm.ConnectionMonitor End Bluetooth autoconnect detection loop
2022-01-18 04:57:08,062 INFO comm.HubClient Connecting to hub using COM3
2022-01-18 04:57:08,063 INFO root Connection state change ConnectionState.DISCONNECTED --> ConnectionState.CONNECTING
2022-01-18 04:57:08,064 ERROR comm.HubClient connection change failed: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)
Traceback (most recent call last):
  File "C:\Users\partsjoo\AppData\Local\lego-hub-tk-main\comm\HubClient.py", line 85, in _connection_changed
    conn.open()
  File "C:\Users\partsjoo\AppData\Local\lego-hub-tk-main\comm\SerialConnection.py", line 37, in open
    self._serial.open()
  File "C:\Users\partsjoo\AppData\Local\Programs\Python\Python39\lib\site-packages\serial\serialwin32.py", line 64, in open
    raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)
2022-01-18 04:57:08,067 INFO root Connection state change ConnectionState.CONNECTING --> ConnectionState.DISCONNECTED
2022-01-18 04:57:08,069 INFO comm.ConnectionMonitor End USB autoconnect detection loop

It can happen when something is already using HUB while you are trying to connect to it. To fix the problem, stop other programs from using HUB when you are trying to connect.

It seems like basic knowledge to the knowledgeable, but maybe a hit printed somewhere on these lines could be useful.

Using monitor.events.console_print prints only ERROR level messages

Hello. I am trying to access print("test") being called in a function running on HUB. But I can only receive ERROR level messages (probably not coming from something_changed). However when running toolkit tools like hubcontrol.py I see that "test" gets printed on INFO level. How to access INFO level from monitor event console_print ?

start_monitoring_on_pc.py

import time

from data.HubMonitor import HubMonitor
from comm.HubClient import HubClient, ConnectionState

connection = 0


class Main:
    client = HubClient()
    hm = HubMonitor(client)

    def __init__(self):
        self.hm.events.console_print += self._console_print
        self.client.start()

    def _console_print(self, msg):
        print(msg)


Main()


def send_heartbeat_to_backend(connection):
    # TODO
    if connection == 0:
        print('HUB is offline')
    elif connection == 1:
        print('Connection established to HUB')
    elif connection == 2:
        if not Main.hm.execution_status[1]:
            print('Main program started on HUB')
        if Main.hm.execution_status[1]:
            print('Main program running')


def send_cube_map_to_backend(map):
    # TODO
    print(map)


while True:
    send_heartbeat_to_backend(connection)
    time.sleep(1)
    if Main.hm.connection_state == ConnectionState.TELEMETRY:
        if connection == 0:
            connection = 1
        elif connection == 1:
            Main.client.program_execute(1)
            connection = 2
    else:
        print('waiting...')
HUB is offline
Connection established to HUB
Main program started on HUB
Main program started on HUB
Main program running
ERROR:root:unrecognized motion sensor value: 1
// expecting print("test") to print here

EDIT:
I noticed your commit... d3b8684 after re-adding these lines I got it working as intended. Please update the docs that by default, these events do no fire, instead they are being logged to file (which I saw actually) but I could not find the root cause for it. That - or better yet, make it optional to log to console or file or both. 👍

Protocol Spec

Hi,

I am the maintainer of sharpbrick/powered-up which is a .NET library for communicating with the Lego Technic Powered Up hubs. In that world, I am used to write software on a PC/Mac/Linux device and instruct the hub what to do. I worked hard with the LWP2 spec and collaborated in the community to get the best experience out of it.

So the question to the Spike/Mindstorm Hub experts: Is the remote protocol of the mindstorms hub a debugging protocol (aka receiving telemetry and messing with the execution of a previous transferred python program) OR is it a true remote control protocol where commands are sent by a controlling PC and then executed by the hub?

I have not found a lot of documentation, so i am bit confused? Also there is a mystical hub to hub protocol which I also found no real information about it.

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.