WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Micropython pyb  (Read 2620 times)

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Micropython pyb
« on: May 26, 2016, 11:58:33 PM »
Hi Bela,

Been seeing you on the micropython forum.
Embedded Micropython uses pyb to talk to hardware, don't have that for RPi version?
Would be nice to figure out how to do i2c stuff in micropython.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Micropython pyb
« Reply #1 on: May 27, 2016, 03:06:41 AM »
In piCore it is the Unix version of MicroPython with os module preinstalled, see /usr/lib/micropython. There is a piCore specific tc.py module also with functions used by the extension loader like reading of kernel version, number of CPU's, dependency lists, etc.

At the moment there are no RPi machine hardware (HAL) module available, someone must make it. As much as possible it must follow the rules I mean use same methods, properties, etc. as other MicroPython implementations are doing it. Which is changing of course, see ongoing discussion at GitHub about that topic.

Many hw stuff can be done via /proc like configuring, reading and writing GPIO, etc. It is easy to code as it requires only file manipulation. Direct programing of hw registers a bit more complicated and requires a C code as well as using interrupts. But you can start with just the simple operations. There are tons of sample codes for RPi written in other languages.

As cPython MicropYthon on Linux is using libffi which makes using of existing libs easy. Study MicroPython modules at GitHub.


Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Micropython pyb
« Reply #2 on: May 27, 2016, 03:58:52 AM »
Ok, that does not mean much to me yet.

In the meantime I wrote some shell script that uses i2cget to read the i2c sensor and format it, then write it to a file.
I then used the micropython code to os.system("xx.sh") the script and then opened the file in micropython to read the data back.
And act as modbus server in 76 lines of code 8)
Clunky but it works.

Done cat /proc/cpuinfo before, can it be used to do GPIO?
I normally use /sys/class/gpio....

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Micropython pyb
« Reply #3 on: May 27, 2016, 04:57:33 AM »
Done cat /proc/cpuinfo before, can it be used to do GPIO?
I normally use /sys/class/gpio....

Yeah, for GPIO it is /sys/class/...
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."