Importing modules in embedded python

Advertisements I’m trying to get module imports to work in embeddable python, but it doesn’t want to work C:\Users\test\Desktop\winpy\python-3.10.10-embed-win32>type run_scripts\script.py from module_test import test print("Hello world!") print(test()) C:\Users\test\Desktop\winpy\python-3.10.10-embed-win32>type run_scripts\module_test.py def test(): return "Test!" C:\Users\test\Desktop\winpy\python-3.10.10-embed-win32>@python.exe run_scripts\script.py Traceback (most recent call last): File "C:\Users\test\Desktop\winpy\python-3.10.10-embed-win32\run_scripts\script.py", line 1, in <module> from module_test import test ModuleNotFoundError: No module named ‘module_test’… Read More Importing modules in embedded python

How can C allocate memory without an OS? (Cases where OS is written in C)

Advertisements I am following a course where we are writing an OS on a microcontroller. The OS is written in C and the instructor initializes stack spaces for each thread in the following way. int32_t TCB_STACK[NUM_OF_THREADS][STACK_SIZE]; How can the memory be allocated if there isn’t any OS already running to service this in the first… Read More How can C allocate memory without an OS? (Cases where OS is written in C)

How to add an image to desktop notification using plyer (PYTHON)

Advertisements How can I add an image to this message iteself (not change the icon)?: from plyer import notification notification.notify( title = ‘testing’, message = ”, app_icon = None, app_name = ‘Notifications’, timeout = 10, ) >Solution : Unfortunately Plyer does not offer to show images in the notification besides an icon. See How to… Read More How to add an image to desktop notification using plyer (PYTHON)

How do I correctly destruct a derived object that was constructed using placement new

Advertisements Say we have a C++ program with this sort of class inheritance: class A { public: virtual ~A() {/* … */} }; class B : public A { public: virtual ~B() {/* … */} }; class C : public A { public: virtual ~C() {/* … */} }; And furthermore, there are specialized memory… Read More How do I correctly destruct a derived object that was constructed using placement new

indexing an element from a volatile struct doesn't work in C++

Advertisements I have this code: typedef struct { int test; } SensorData_t; volatile SensorData_t sensorData[10]; SensorData_t getNextSensorData(int i) { SensorData_t data = sensorData[i]; return data; } int main(int argc, char** argv) { } It compiles with gcc version 8.3, but not with g++. Error message: main.c: In function ‘SensorData_t getNextSensorData(int)’: main.c:8:34: error: no matching function… Read More indexing an element from a volatile struct doesn't work in C++

Can I initialize a std::array<uint8_t with a string literal?

Advertisements I write a lot of C code interacting with instruments using UART serial ports. I’m starting a new project where I’m trying to use a more object oriented approach with C++. Here’s how I’ve defined and sent commands in the past using C. uint8_t pubx04Cmd[] = "$PUBX,04*37\r\n"; HAL_UART_Transmit(&hUART1, pubx04Cmd, sizeof(pubx04Cmd), 5000); Which is pretty… Read More Can I initialize a std::array<uint8_t with a string literal?