codebugtools / codebug_tether Goto Github PK
View Code? Open in Web Editor NEWControl CodeBug over Serial USB.
License: GNU General Public License v3.0
Control CodeBug over Serial USB.
License: GNU General Public License v3.0
Test case:
PS C:\Users\David\Documents\GitHub\codebug_tether> python
ActivePython 2.7.6.9 (ActiveState Software Inc.) based on
Python 2.7.6 (default, Feb 27 2014, 14:15:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
from codebug_tether import CodeBug
cb = CodeBug('com6')
cb.set_leg_io(0, 0)
cb.set_output(0,1)
cb.set_leg_io(1, 0)
cb.set_output(1,1)
cb.set_leg_io(2, 0)
cb.set_output(2,1)
exit()
PS C:\Users\David\Documents\GitHub\codebug_tether>
The effect of this is that each of the 3 Legs is set HIGH in turn, but is reset to LOW when the next Leg in the sequence is set HIGH, so at the end of the test only Leg2 is High.
I expected each Leg to be set/cleared independently.
Is this a bug, or have I misunderstood the intent of the API? If the latter, is there a simple way to set/reset each Leg independently please?
[This is using version = '0.4.1' of the codebug_tether module and associated .cbg firmware.]
Hi
I'm trying to use set_pullup to set leg 0 to high, using set_pullup(0, 1) but keep getting an error that:
self.set_bit(CHANNEL_INDEX_PULLUPS, input_index, direction)
NameError: name 'direction' is not defined
Looking into the core.py file on here, the set_pullup takes three parameters, self, input_index, and state. This state parameter is never used but an undefined (probably) variable direction, is then used to call self.set_bit. Should this be state instead?
Cheers
Dave
Additional package which must be installed for tethering to work:
python3-serial
E.g. on Debian-type systems: sudo apt-get install python3-serial
I don't seem able to set a leg's output state :(
I've tried this code but either I've mis-understood the cb.set_output function or it doesn't work
Help please :)
import os
import sys
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)
from codebug_tether import CodeBug
import time
if __name__ == '__main__':
cb = CodeBug()
cb.clear()
for i in range(3):
cb.set_output(0,True)
time.sleep(1)
cb.set_output(0,False)
time.sleep(1)
Using codebug_tether with pwm_freq(1000) the actual output frequency appears to be 3kHz on an oscilloscope. Similarly, using pwm_freq(2000) actually outputs 6kHz. This seems to reproduce on both 0.7.0 and 0.7.3 firmware. However, when using a code block with "start tone (Hz) [1000]" the output is exactly 1kHz on the oscilloscope as expected.
The code used is as follows:
cb = codebug_tether.CodeBug()
cb.set_leg_io(0, IO_PWM_OUTPUT)
cb.pwm_freq(1000)
time.sleep(2)
cb.pwm_off()
Following the guide on the readthedocs website, I get an AssertionError when trying the first set_row line:
codebug.set_row(0, 5)
Not sure it's connected to the given device - how do I check? Is this the right place to ask for support?
I'm getting this
[413775.644294] ------------[ cut here ]------------
[413775.644319] WARNING: CPU: 2 PID: 8289 at drivers/usb/core/urb.c:450 usb_submit_urb+0x1cc/0x4b8()
[413775.644338] usb 1-1.4: BOGUS urb xfer, pipe 3 != type 1
[413775.644356] Modules linked in: cdc_acm sg binfmt_misc nfsd rtc_ds1307 cfg80211 rfkill rpcsec_gss_krb5 8188eu(O) evdev i2c_bcm2708 spi_bcm2835 uio_pdrv_genirq uio bcm2708_rng i2c_dev snd_bcm2835 snd_pcm snd_timer snd fuse ipv6
[413775.644528] CPU: 2 PID: 8289 Comm: python3 Tainted: G W O 4.0.9-v7+ #807
[413775.644536] Hardware name: BCM2709
[413775.644555] [<800175bc>] (unwind_backtrace) from [<80012fd4>] (show_stack+0x20/0x24)
[413775.644572] [<80012fd4>] (show_stack) from [<8054720c>] (dump_stack+0x98/0xe0)
[413775.644589] [<8054720c>] (dump_stack) from [<8002507c>] (warn_slowpath_common+0x8c/0xc8)
[413775.644607] [<8002507c>] (warn_slowpath_common) from [<800250f8>] (warn_slowpath_fmt+0x40/0x48)
[413775.644626] [<800250f8>] (warn_slowpath_fmt) from [<803c31cc>] (usb_submit_urb+0x1cc/0x4b8)
[413775.644645] [<803c31cc>] (usb_submit_urb) from [<7f05c6e8>] (acm_submit_read_urb+0x50/0x94 [cdc_acm])
[413775.644669] [<7f05c6e8>] (acm_submit_read_urb [cdc_acm]) from [<7f05e194>] (acm_submit_read_urbs.constprop.22+0x38/0x58 [cdc_acm])
[413775.644693] [<7f05e194>] (acm_submit_read_urbs.constprop.22 [cdc_acm]) from [<7f05e2b4>] (acm_port_activate+0x100/0x154 [cdc_acm])
[413775.644713] [<7f05e2b4>] (acm_port_activate [cdc_acm]) from [<8033ab2c>] (tty_port_open+0x8c/0xcc)
[413775.644737] [<8033ab2c>] (tty_port_open) from [<7f05cef8>] (acm_tty_open+0x2c/0x30 [cdc_acm])
[413775.644757] [<7f05cef8>] (acm_tty_open [cdc_acm]) from [<80332f64>] (tty_open+0xb8/0x5c8)
[413775.644774] [<80332f64>] (tty_open) from [<80143c3c>] (chrdev_open+0xb0/0x188)
[413775.644792] [<80143c3c>] (chrdev_open) from [<8013d620>] (do_dentry_open.isra.15+0xfc/0x314)
[413775.644809] [<8013d620>] (do_dentry_open.isra.15) from [<8013d8d4>] (vfs_open+0x54/0x58)
[413775.644827] [<8013d8d4>] (vfs_open) from [<8014b14c>] (do_last.isra.51+0x124/0xc8c)
[413775.644845] [<8014b14c>] (do_last.isra.51) from [<8014d7e0>] (path_openat+0x338/0x5a0)
[413775.644861] [<8014d7e0>] (path_openat) from [<8014e938>] (do_filp_open+0x3c/0x90)
[413775.644877] [<8014e938>] (do_filp_open) from [<8013e928>] (do_sys_open+0x10c/0x1dc)
[413775.644895] [<8013e928>] (do_sys_open) from [<8013ea24>] (SyS_open+0x2c/0x30)
[413775.644912] [<8013ea24>] (SyS_open) from [<8000eb40>] (ret_fast_syscall+0x0/0x54)
[413775.644921] ---[ end trace 0dd060d51e7292bc ]---
When I connect my Codebug running the serial tether CBG.
/dev/ttyACM0
appears but I can't open it with pyserial or minicom.
The install instructions which are in readthedocs (and also on CodeBug's Activities) are missing a crucial library that doesn't come installed in vanilla python (at least not on the Mac)
pyserial
Here's what happens on a brand new python virtualenv:
(hax) mjl@milo:codebug$ python
Python 3.5.2 (default, Jul 28 2016, 21:28:00)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codebug_tether
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mjl/lib/hax/lib/python3.5/site-packages/codebug_tether/__init__.py", line 1, in <module>
from codebug_tether.core import (CodeBug,
File "/Users/mjl/lib/hax/lib/python3.5/site-packages/codebug_tether/core.py", line 3, in <module>
import serial
ImportError: No module named 'serial'
>>>
If the instructions are updated to add pyserial as well as codebug_tether (or set it as a dependency for the package) then it will solve for other kids playing along:
pip install codebug_tether pyserial
Then it works.
Let's try:
(hax) mjl@milo:codebug$ pip install pyserial
Collecting pyserial
Downloading pyserial-3.2.1-py2.py3-none-any.whl (189kB)
100% |████████████████████████████████| 194kB 967kB/s
Installing collected packages: pyserial
Successfully installed pyserial-3.2.1
Now import the module:
(hax) mjl@milo:codebug$ python
Python 3.5.2 (default, Jul 28 2016, 21:28:00)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codebug_tether
>>>
Happy Hacking!
Picture of the issue: https://twitter.com/sezzyann72/status/739477225637052416
It looks like permissions on /dev/ttyS0
are not set up correctly. When you type:
ls -l /dev/ttyS0
You should get the following readout:
crw-rw---- 1 root dialout 4, 64 Jun 6 10:56 /dev/ttyS0
Also,
groups
should return:
pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
The important group to have is dialout
.
This error can usually be fixed with:
sudo apt-get update
sudo apt-get upgrade
I'm opening this issue for discussion.
While trying out ScratchCodeBug...
Initially, copying and executing codebug_tether.cbg on my CodeBug, connected to my Win7 laptop, failed. In Device Manager it showed "drivers not installed" (see http://snag.gy/ll4LY.jpg) and no sign of a USB Serial Port.
I tried downloading and installing the FTDI driver and now have a USB Serial Port but "device cannot start" (see http://snag.gy/BKARo.jpg).
From comparison with a working Win/CodeBug setup I gather I may need a driver from Microchip Technology Inc (see http://snag.gy/uNoyv.jpg). Current next step is try to find one...
When I use tether firmware v0.8.0, digital outputs 0 and 1 don't seem to work properly. They are at about 0.5 volts all the time. Legs 2 and 3 work as expected. When I use firmware v0.7.3, this doesn't happen and all legs work as expected.
Digital and analogue inputs work as expected in both v0.7.3 and v0.8.0 firmware version. PWM not tested.
Has adding the servo support somehow affected digital outputs?
Getting this error message after loading the tether firmware
Loading in a normal .cbg file works fine
Its showing up as having an Invalid Configuration Descriptor in Windows device manager
using Win 8.1 64bit
I can see how the code gets installed, I can get the cbg file installed on my Codebug all from my Raspberry Pi (it appears as /dev/sda1 when I hold button A and plug it in). But, the missing piece is how to wire RPi pins #8 (TXD), #10 (RXD) & #6 (GND) to my Codebug.
Or if I use a FTDI USB serial how to wire TXD, RXD and GND to the Codebug.
Do I need to be worried about 3V3 vs 5V0?
I've got the same issue with your I2C tethering.
Hi, we have the same problem as hippyjim had.
None of the commands work, same error always.
Should mention install pySerial in the tutorial btw for the noobs like me
Using Win10, Codebug is connecting as COM2
Downloaded the 0.8.5 cbg
import codebug_tether
codebug = codebug_tether.CodeBug()
codebug.set_pixel(2, 1, 1)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in
codebug.set_pixel(2, 1, 1)
File "C:\Users\Asus\AppData\Local\Programs\Python\Python35-32\lib\site-packages\codebug_tether\core.py", line 313, in set_pixel
self.set_bit(channel, bit_index, state)
File "C:\Users\Asus\AppData\Local\Programs\Python\Python35-32\lib\site-packages\codebug_tether\serial_channel_device.py", line 151, in set_bit
self.or_mask(channel_index, 1 << bit_index)
File "C:\Users\Asus\AppData\Local\Programs\Python\Python35-32\lib\site-packages\codebug_tether\serial_channel_device.py", line 146, in or_mask
bytes((mask,)))
File "C:\Users\Asus\AppData\Local\Programs\Python\Python35-32\lib\site-packages\codebug_tether\serial_channel_device.py", line 200, in transaction
assert self.serial_port.read(1) == ACK_BYTE
AssertionError
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.