why linux and windows builds

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: why linux and windows builds

Post by pfalcon » Wed Nov 25, 2015 1:48 pm

on BBB running make test I get the following...
That's pretty bad, it shouldn't be like that. The next step would be writing a script which diffs expected with actual (bad) output. If you can do that, please post the output as a bug to https://github.com/micropython/micropython . If not, you can either diff manually, or wait when someone else writes such a script. All in all, I'd treat the issues above seriously, and would be happy to look into them - as long as there's enough information provided.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: why linux and windows builds

Post by pfalcon » Wed Nov 25, 2015 1:52 pm

so my question is... how can I do i2c access anyone done this?
Nope, unlikely. But we're approaching that (being able to use I2C on any board with minimal efforts), e.g. with https://github.com/micropython/micropython/pull/1611 . But it would take some time to get it to state when it "just works". The limiting factor here is that so far nobody really needed to use I2C communication on a Linux board with MicroPython. So, the more there're people interested in it, and more active they are, the sooner it will be possible.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Peter.Kenyon
Posts: 70
Joined: Wed Oct 14, 2015 5:07 pm

Re: why linux and windows builds

Post by Peter.Kenyon » Wed Nov 25, 2015 3:03 pm

@pflacon thanks, ill try to do as you ask, but I'm a real newbie at this stuff.

fwiw I was thinking of using ffi to talk to the libc library... cos to do i2c I just need open and ioctl, (as per java jna implementation).
My original implementation was in java but I discovered python and fell in love, at the moment I am using the bbb default python, and the pybbbio library, but it would be fun to use upython instead

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: why linux and windows builds

Post by pfalcon » Wed Nov 25, 2015 4:48 pm

Good plan. If you have a known working library, interfacing with it using FFI is the most straightforward way. You can find a lot of FFi usage examples in https://github.com/micropython/micropython-lib
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Peter.Kenyon
Posts: 70
Joined: Wed Oct 14, 2015 5:07 pm

Re: why linux and windows builds

Post by Peter.Kenyon » Wed Nov 25, 2015 7:13 pm

actually I was hoping to use ffi directly to libc...

Code: Select all

import ffi

O_RDWR = 2
I2C_SLAVE = \x0703

libc = ffi.open("libc.so.6")

open=libc.func("i", "open", "si")
ioctl=libc.func("i", "ioctl", "iii")
read=libc.func("i", "read", "ipi")
write = libc.func("i", "write", "ipi")
I have got open("/dev/i2c-2", O_RDWR) to work
also ioctl(fd, I2C_SLAVE, 0x48)

but struggling with the read and write any help gratefully appreciated.
ps doesn't this mean that this would work on any Linux distro? with an i2c file api?

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: why linux and windows builds

Post by pfalcon » Wed Nov 25, 2015 8:28 pm

ps doesn't this mean that this would work on any Linux distro? with an i2c file api?
Yes. As soon as you figure out that ioctl and read/write stuff. But for example using bitbanging will work just anywhere, not just on Linux (and "on Linux" means "Linux kernel which has appropriate I2C driver"). Of course, perhaps slowly, etc. But who cares - what's really slow is figuring out that boring ioctl and read/write stuff. (Though of course it needs to be done once, and if you take care to share it with other people, they'll do something else cool which may be of use to you later.)

As for specifics, maybe someone else can help. If I'd do it, I'd take some existing known working code (e.g. i2c-tools) and looked how it does that.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: why linux and windows builds

Post by dhylands » Wed Nov 25, 2015 8:49 pm

I thought I posted this but I must have forgotten to hit Submit.

I have some C code which uses the I2C_RDWR ioctl call to talk to i2c devices.
https://github.com/dhylands/robostix/bl ... /i2c-api.c

In particular, the core bit is the I2cTransfer function. It has a bunch of wrappers which convert many of the various smbus protocols into a call to I2cTransfer.

The smbus spec is here: http://smbus.org/specs/SMBus_3_0_20141220.pdf and chapter 6 covers the various protocols.

Peter.Kenyon
Posts: 70
Joined: Wed Oct 14, 2015 5:07 pm

Re: why linux and windows builds

Post by Peter.Kenyon » Thu Nov 26, 2015 6:23 am

thanks d - helpful as usual.
for my purposes, its easy to do, what I'm not clear about is how to pass in/out buffers to the ffi calls for read/write.
when I tried something I got a segmentation fault and it bombed out of micropython, anyway must be doable so ill plod on

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: why linux and windows builds

Post by bmarkus » Thu Nov 26, 2015 6:24 am

On Raspberry Pi the result is:

Code: Select all

454 tests performed (15564 individual testcases)
453 tests passed
21 tests skipped: cmd_showbc cmd_verbose native_closure native_const native_misc viper_args viper_binop_arith viper_binop_comp viper_binop_comp_imm viper_binop_multi_comp viper_cond viper_error viper_misc viper_ptr16_load viper_ptr16_store viper_ptr32_load viper_ptr32_store viper_ptr8_load viper_ptr8_store viper_subscr extra_coverage
1 tests failed: machine_mem
Makefile:144: recipe for target 'test' failed
make: *** [test] Error 1
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: why linux and windows builds

Post by bmarkus » Thu Nov 26, 2015 7:31 am

On Centos7:

Code: Select all

472 tests performed (15721 individual testcases)
472 tests passed
3 tests skipped: cmd_showbc cmd_verbose extra_coverage
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

Post Reply