Custom port A9G module: help wanted
Re: Custom port A9G module: help wanted
So what kind of API should I implement for the scenario: "SMS recieved", for example?
Re: Custom port A9G module: help wanted
I have the following piece of code (porting esp32 sockets):
It fails at the assignment with error: expected identifier before ‘(’ token. Any idea?
Code: Select all
#include "py/stream.h"
void function(void){
mp_stream_p_t x;
x.read = NULL;
}
Re: Custom port A9G module: help wanted
That code by itself should compile.
Something in the .h is causing the error.
Sent from my iPhone using Tapatalk Pro
Something in the .h is causing the error.
Sent from my iPhone using Tapatalk Pro
Re: Custom port A9G module: help wanted
Here you go with the header file: https://github.com/pulkin/micropython/b ... y/stream.h
Re: Custom port A9G module: help wanted
To figure out what's going on, you need to look at the preprocessed source file.
On the pyboard, there is a rule in the makefile to create preprocessed files.
If, for example, I was trying to see the preprocessed file for ports/stm32/adc.c it produces an object file build-PYBV11/adc.o so I could ask do: (i.e. replace .o with .pp) and the adc.pp file will have the preprocessed file that the compiler sees.
This will typically make it easier to figure out what's actually going on, which will often wind up being some macro being defined in an unexpected way.
On the pyboard, there is a rule in the makefile to create preprocessed files.
If, for example, I was trying to see the preprocessed file for ports/stm32/adc.c it produces an object file build-PYBV11/adc.o so I could ask do:
Code: Select all
make BOARD=PYBV11 build-PYBV11/adc.pp
This will typically make it easier to figure out what's actually going on, which will often wind up being some macro being defined in an unexpected way.
Re: Custom port A9G module: help wanted
Given I have this in the pp:
is it reasonable to assume that our Chinese friends bundle a 'read' macro that was substituted? How do I get rid of it without changing outer files and imports?
Code: Select all
mp_stream_p_t x;
x.(g_InterfaceVtbl->lwip_read) = NULL;
Re: Custom port A9G module: help wanted
It would seem that way.
You can put in your code after the #includes
However, read seems pretty generic and that #define might mess up other things which you might not be able to fix as easily (just a heads up)
If the #include file containing the #define read is guarded (i.e. protects itself from being included multiple times) then you might be able to #include it, #undef read and then go along with your other #includes.
If you search for read in the .pp file you should see the #define (if you use the same options that MicroPython is using for producing the .pp files it keeps all of the #defines around)
You can put
Code: Select all
#if defined(read)
#undef read
#endif
However, read seems pretty generic and that #define might mess up other things which you might not be able to fix as easily (just a heads up)
If the #include file containing the #define read is guarded (i.e. protects itself from being included multiple times) then you might be able to #include it, #undef read and then go along with your other #includes.
If you search for read in the .pp file you should see the #define (if you use the same options that MicroPython is using for producing the .pp files it keeps all of the #defines around)
Re: Custom port A9G module: help wanted
What kind of mechanism finalizes objects (i.e. closes files on reference count = 0) in micropython? Is it GC? What do I need implement for it?
Re: Custom port A9G module: help wanted
There’s no reference counting in micropython unless you implement it yourself.pulkin wrote:What kind of mechanism finalizes objects (i.e. closes files on reference count = 0) in micropython? Is it GC? What do I need implement for it?
You have to enable the macro MICROPY_ENABLE_FINALISER.
Also for your object, you need to define __del__ because finalization calls that method.
If you want reference counting for some resource, you would implement that in the constructor and __del__
Sent from my iPhone using Tapatalk Pro
Re: Custom port A9G module: help wanted
OK, to try this out I need to also enable gc. So my question is: what does micropython gc actually do? What is the difference between micropython running with gc and without it?