GithubHelp home page GithubHelp logo

greatscottgadgets / libgreat Goto Github PK

View Code? Open in Web Editor NEW
31.0 31.0 24.0 421 KB

a library to help you do Great things

License: BSD 3-Clause "New" or "Revised" License

CMake 3.40% C 83.49% Python 12.35% Assembly 0.76%

libgreat's People

Contributors

agkunkle avatar antoinevg avatar aussieklutz avatar doegox avatar fluxius avatar grvvy avatar ktemkin avatar martinling avatar miek avatar mossmann avatar osterwood avatar qyriad avatar straithe 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgreat's Issues

Release libgreat v2023.2.2

This is the tracking issue for the libgreat v2023.2.2 release.

Issues

  1. documentation enhancement
    straithe
  2. bug
    antoinevg

Review, merge or close outstanding pull requests

  1. antoinevg

ImportError: No module named functools_lru_cache

I needed an additional package installed for greatfet to run. Running greatfet info throws this error:

Traceback (most recent call last):
  File "/usr/local/bin/greatfet", line 6, in <module>
    from greatfet.commands.gf import main
  File "/usr/local/lib/python2.7/dist-packages/greatfet/__init__.py", line 3, in <module>
    from .greatfet import GreatFET
  File "/usr/local/lib/python2.7/dist-packages/greatfet/greatfet.py", line 5, in <module>
    from .board import GreatFETBoard
  File "/usr/local/lib/python2.7/dist-packages/greatfet/board.py", line 12, in <module>
    from pygreat.board import GreatBoard
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 15, in <module>
    from pygreat.comms import CommsBackend
  File "/usr/local/lib/python2.7/dist-packages/pygreat/comms.py", line 21, in <module>
    from backports.functools_lru_cache import lru_cache as memoize_with_lru_cache
ImportError: No module named functools_lru_cache

Workaround is to install:
sudo apt install python-backports.functools-lru-cache

Linux 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

build failing on newer python versions

libgreat is not compatible with newer python versions.

greatfet/libgreat/host $ python setup.py build
WARNING: The wheel package is not available.
Traceback (most recent call last):
  File "/home/user/greatfet/libgreat/host/setup.py", line 24, in <module>
    setup(
  File "/usr/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib64/python3.10/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 455, in __init__
    _Distribution.__init__(self, {
  File "/usr/lib64/python3.10/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 807, in finalize_options
    ep(self)
  File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 814, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/home/user/greatfet/libgreat/host/.eggs/even_better_setuptools_git_version-1.0.7-py3.10.egg/even_better_setuptools_git_version.py", line 83, in validate_version_config
    if not isinstance(config, collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'
$ python -V
Python 3.10.0
$ cat /etc/fedora-release 
Fedora release 35 (Thirty Five)

it seems to be the change mentioned here:

Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module.

googling for "python collections.Mapping removed" finds various other projects dealing with the issue, so probably a backwards-compatible way to change this can be found in one of them.

Update pygreat README.md

The pygreat README lacks detail, and still describes this as an experimental repo. It should probably be updated to at least mention (tersely) that it's a library with support for the LPC43xx, and which is meant to support GreatFET and forthcoming boards.

LCP4330 does not have the pins defined for the additional UARTS:

Looking in libgreat, the LCP4330 does not have the pins defined for the additional UARTS:
https://github.com/greatscottgadgets/libgreat/blob/master/firmware/platform/lpc43xx/drivers/platform_uart.c

/**
 * Mapping that provides the location of the default pins for each UART.
 */
uart_pins_t uart_pins[] = {
	{
		.tx = { .group = 9, .pin = 5, .function = 7 },
		.rx = { .group = 9, .pin = 6, .function = 7 }

		// TODO: add flow control pins!
	},

	// FIXME: add the other UARTS!
};

Originally posted by @aussieklutz in greatscottgadgets/greatfet#383 (comment)

Request for pygreat pip3 package update

Hello there,

I'm not quite sure where to put this ticket. I know you all have done a fantastic job of keeping the firmware of the GreatFET One and the software in sync, packaged together (currently 2019.9.1).

Currently the pygreat-2019.9.1 package is missing a somewhat "critical" fix: 655a6a6 (addresses #7)

Without that update, anyone using Python 3.5+ won't be able to use the library. comms.py crashes right away during device setup.

I was wondering: can you package up a 2019.12.1 version of pygreat into pypi?

Tested on Ubuntu 18.04.3 LTS, Python 3.6.9 (currently the default install for Ubuntu 18)

Thank you for your time, and keep up the great work!

Temporary Workaround for Ubuntu 18 Users

As a dirty workaround to anyone using Ubuntu 18 that happens upon this issue, you can manually work around by changing this line in comms.py (check your stack trace for the dist-packages location of pygreat):

            if match.groups(1) is None:
                return 1
            else:
                return int(match.groups(1))

To:

            if match.groups(1) is None:
                return 1
            else:
                return int(match.groups(1)[0])

re.match with Python 3.5

I am attempting to use a GreatFET ONE with the Facedancer project on Ubuntu 16.04.06 LTS using Python 3.5. Trying to run any of the facedancer-XX.py examples results in the following exception:

GreatDancer initialized
GreatDancer connected device USB keyboard device
-- Reset requested! --
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 772, in execute_command
    result = self.unpack(out_format, raw_result)
  File "/usr/local/lib/python3.5/dist-packages/backports/functools_lru_cache.py", line 137, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 609, in unpack
    bytes_consumed, raw_bytes = cls._split_off_bytes_for_format(subformat, raw_bytes)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 417, in _split_off_bytes_for_format
    num_bytes_consumed = cls._get_bytes_consumed_by_format(format_string, raw_bytes)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 391, in _get_bytes_consumed_by_format
    if match[1] is None:
TypeError: '_sre.SRE_Match' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./facedancer-keyboard.py", line 14, in <module>
    d.run()
  File ".../Facedancer/facedancer/USBDevice.py", line 166, in run
    self.scheduler.run()
  File ".../Facedancer/facedancer/core.py", line 512, in run
    task()
  File ".../Facedancer/facedancer/USBDevice.py", line 84, in <lambda>
    self.scheduler.add_task(lambda : self.maxusb_app.service_irqs())
  File ".../Facedancer/facedancer/backends/GreatDancerApp.py", line 747, in service_irqs
    self._handle_setup_events()
  File ".../Facedancer/facedancer/backends/GreatDancerApp.py", line 359, in _handle_setup_events
    self._handle_setup_event_on_endpoint(i)
  File ".../Facedancer/facedancer/backends/GreatDancerApp.py", line 374, in _handle_setup_event_on_endpoint
    data = self.api.read_setup(endpoint_number)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 1088, in method
    timeout=timeout, max_response_length=max_response_length, encoding=encoding, *arguments)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 1243, in execute_command
    out_format, *arguments, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 779, in execute_command
    future_utils.raise_with_traceback(outer_exception, sys.exc_info()[2])
  File "/usr/local/lib/python3.5/dist-packages/future/utils/__init__.py", line 421, in raise_with_traceback
    raise exc.with_traceback(traceback)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 772, in execute_command
    result = self.unpack(out_format, raw_result)
  File "/usr/local/lib/python3.5/dist-packages/backports/functools_lru_cache.py", line 137, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 609, in unpack
    bytes_consumed, raw_bytes = cls._split_off_bytes_for_format(subformat, raw_bytes)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 417, in _split_off_bytes_for_format
    num_bytes_consumed = cls._get_bytes_consumed_by_format(format_string, raw_bytes)
  File "/usr/local/lib/python3.5/dist-packages/pygreat/comms.py", line 391, in _get_bytes_consumed_by_format
    if match[1] is None:
TypeError: unexpected return RPC `read_setup`; innner message: '_sre.SRE_Match' object is not subscriptable; format: <8X

I believe this is due to how Python changed the behavior of re.match() in Python 3.6. Just wanted you to be aware as I don't think the pip-installed greatfet module enforces that version to be used.

I just made a local fix by updating match[1] to match.groups(1) and all seems to be working fine now.

Thanks for supporting such a cool project!

AttributeError: 'array.array' object has no attribute 'tobytes'

Executing greatfet info results in error:

  File "/usr/local/bin/greatfet_info", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/greatfet/commands/greatfet_info.py", line 94, in main
    devices = GreatFET(find_all=True)
  File "/usr/local/lib/python2.7/dist-packages/greatfet/greatfet.py", line 29, in GreatFET
    return GreatFETBoard.autodetect_all(**board_identifiers)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 105, in autodetect_all
    subclass_devices = subclass.all_accepted_devices(**device_identifiers)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 151, in all_accepted_devices
    if cls.accepts_connected_device(**identifiers):
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 168, in accepts_connected_device
    potential_device = cls(**device_identifiers)
  File "/usr/local/lib/python2.7/dist-packages/greatfet/boards/rad1o.py", line 24, in __init__
    super(Rad1oBadge, self).__init__(**device_identifiers)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 245, in __init__
    if self.HANDLED_BOARD_IDS and (self.board_id() not in self.HANDLED_BOARD_IDS):
  File "/usr/local/lib/python2.7/dist-packages/pygreat/board.py", line 274, in board_id
    return self.apis.core.read_board_id()
  File "/usr/local/lib/python2.7/dist-packages/pygreat/comms.py", line 1088, in method
    timeout=timeout, max_response_length=max_response_length, encoding=encoding, *arguments)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/comms.py", line 1243, in execute_command
    out_format, *arguments, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/comms.py", line 761, in execute_command
    None, max_response_length, comms_timeout, pretty_name, rephrase_errors)
  File "/usr/local/lib/python2.7/dist-packages/pygreat/comms_backends/usb.py", line 288, in execute_raw_command
    return response.tobytes()
AttributeError: 'array.array' object has no attribute 'tobytes'

System info:

  • Linux 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Python 2.7.15rc1

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.