MicroPython ESP32 CanBus - can-bus

Good morning, I've been wanting to use the CAN module from the machine library on an ESP32 based board, unfortunatelly, as I thought, I'm getting an error when trying to import it
>>> from machine import CAN
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'CAN'
Is there any way to enable the CAN module on an ESP32 board? I'm following this example and it's written:
[...] The ESP32 has a built-in CAN controller, but the transceiver needs to be added externally. [...]
It states that it should be possible to use the module on an ESP32 board.

According to the generic micropython documentation, it seems to have CAN only on the pyboard.
The documentation you reference is specific to the micropython firmware for pycom boards.
So whether a board does or does not support the CAN bus will depend on the hardware and firmware it comes with.

Related

Is it possible to update micropython via wifi?

I wanted to update the application of an ESP8266 that I have very little physical access to. The new application uses the function uasyncio.create_task(coro) which is not available in Micropython 1.12. Fortunately I was able to replace the function with uasyncio.ensure_future(obj).
Nevertheless, I have the question of whether the area in the flash with Micropython can be updated via WLAN at the runtime of the "OS" Micropython?
Does Micropython run completely in RAM?
A Linux kernel, for example, can easily be exchanged at runtime so that the new kernel is loaded at the next boot.
Yes, Over The Air (OTA) updates are possible. Your device has to be configured for OTA updates before hand with two OTA partitions. MicroPython will run from one of the OTA partitions. You can use MicroPython to retrieve and write new firmware to the other OTA partition. When you perform a reset the processor will start the application in the other OTA partition. You can do this over and over again ping-ponging between the two OTA partitions.
See these links for some examples

Xilinx Zynq peripheral drivers

I have started to develop software for the ZYNQ 7020 SoC from Xilinx. I have finished several tutorials and I have found that whenever I use some predefined block in the PL (for example GPIO controller) then associated software driver for that peripheral is automatically generated. Does anybody know whether this is true only for the predefined blocks or also for user developed blocks? Thanks.
I have found in my opinion useful document regarding the process of custom IP block drivers development.
The tools can't automatically write your driver, but if you package your IP block and driver in the right format you can do the same type of thing. Look here for some more info on how to do that: Is there a way to pass a design parameter from a custom IP to software

ALSA, TinyALSA support in Android Things for Raspberry Pi 0.5.1-devpreview

The 0.5.1-devpreview BSP for RPI3 comes with libtinyalsa.so, libalasautils.so but seemingly no adb shell commandline support for audio.
We are designing a custom audio board (with audio processor) for use with Android Things and Raspberry Pi and we would typically use ALSA utilities and custom kernel drivers for accessing this board under Raspian.
It is possible the default Android Things I2S peripheral drivers and Peripheral Manager support the stream interfaces we need (the same way the VoiceHat drivers were wrapped), but we have little to no information on the default drivers in the RPI3 BSP, and we don't have any information on how to override the default drivers in Android Things without a distro rebuild.
Seems silly to write a Native C++ low-level peripheral driver when so many audio processor companies already provide ALSA-ready ASoC drivers for device source tree use.
Best practices for writing your own audio driver for Android Things?
The VoiceHat driver is one example of how to do a userspace audio driver.
If you're using a custom audio board, you should be aware of the audio chip the board uses. Looking at that chip's datasheet, you should be able to use the same peripheral I/O (UART, GPIO, I2C, SPI) to configure the connection and read/write data over the I2S bus.
In the Google Assistant sample, the app registers the VoiceHat at the beginning of the activity and unregisters it at the end of the activity.

I can not send program to ESP8266 module

Yesterday I got ESP8266, NodeMCU v2.0. I have a problem with module. I Use Esplorer IDE. I have simple code in LUA language.
gpio.mode(4,gpio.OUTPUT)
gpio.write(4,gpio.LOW)
wifi.setmode(wifi.STATION)
wifi.sta.config("Livebox-C408","7255E6262488CC90482CE6F264")
print(wifi.sta.getip())
When I send program to ESP8266, Esplorer shows below error.
stdin:2: '=' expected near 'a'
stdin:2: ')' expected (to close '(' at line 1) near 'TATION'
Sometimes(~10%) I can send above program to ESP8266 without problem. In my opinion, ESP8266 is damaged. What do you think about my problem?
Anticipating your questions, login and password to my home wi-fi are correct.
A few things:
There's no such thing as NodeMCU v2.0. What you probably mean is v2 or 1.0. v1 was revision 0.9. See my comparison for details.
Your code is doomed to "fail" because it doesn't consider the fact that wifi.sta.config() is asynchronous i.e. it won't block until an IP address was assigned. print(wifi.sta.getip()) will eventually print nil. We have an example for a better boot sequence in the docs.
Your device most likely is not damaged.
In the ESPlorer settings tinker with the turbo and dumb modes. I have "Turbo Mode" on and "Dumb Mode" off. Futhermore, set your baud rate to 115'200.
In case you haven't done so already I strongly suggest to upgrade your firmware to a recent version. See here how to build it.

How can I control the arduino interface using lua

I have an arduino galileo board, which I'm running using Intel's image on a micro-sd card.
I already manage to run basic Lua scripts on it.
I want to run a Lua script on the board (Intel's image) and interact with the arduino interface - for example be able to turn on a led or read sensor data. This is very simple to do when using sketch directly, where you have straight forward API to turn on specific pin that is connected to a led. Same goes for reading input from a pin (check if sensor is sending data).
Is there a Lua library that has such access to the pins? or should I somehow connect the Lua script to the Arduino API?
The script will already run on the board.
Thanks.
what you want to do is similar to the Firmdata; it is a processing and arduino sketch that will use arduino as a mere "executor" of a pseudo language over serial.
That means many arduino command are mapped to a specific serial command, for example 'aX' may means do a digitalRead, where X is the pin number, 'bX' do an analogRead and so, obviusly arduino will then send back the reading to your host.
Drawback are that you are limited by serial (or any other bus) throughput. That means, if you want to just fast-prototipe something, it it a good solution, but when you need to code time-sensistive (or specialized) code, then you need to create your own function, called by your own command, witch probabily as a custom response.. pratically you are writing a custom program, and the ardiuno (and LUA) sketch become a mere string parser.
On galileo, the arduino is connected by serial port, as it is needed for sketch upload, so as long as LUA give you some library to manipulate serial port, you are good to go for this solution.

Resources