Created
July 2, 2025 09:36
-
-
Save benevpi/a1158ad136fdc55f3aceda26143874e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Python.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include "piolib.h" | |
#include "ws2812.pio.h" | |
static PyObject* test(PyObject *self, PyObject *args) { | |
printf("test\n"); | |
Py_RETURN_NONE; | |
} | |
//what if we re-setup the pio each time. Is this really necessary? Maybe look into using module state memory | |
static PyObject* testpio(PyObject *self, PyObject *args) { | |
PIO pio; | |
pio = pio0; | |
printf("testpio\n"); | |
pio_close(pio); | |
printf("closing pio\n"); | |
Py_RETURN_NONE; | |
} | |
// Exported methods are collected in a table | |
PyMethodDef method_table[] = { | |
{"test", (PyCFunction) test, METH_VARARGS, "Method docstring"}, | |
{"testpio", (PyCFunction) testpio, METH_VARARGS, "Method docstring"}, | |
{NULL, NULL, 0, NULL} // Sentinel value ending the table | |
}; | |
// A struct contains the definition of a module | |
PyModuleDef mymodule_module = { | |
PyModuleDef_HEAD_INIT, | |
"mymodule", // Module name | |
"This is the module docstring", | |
-1, // Optional size of the module state memory | |
method_table, | |
NULL, // Optional slot definitions | |
NULL, // Optional traversal function | |
NULL, // Optional clear function | |
NULL // Optional module deallocation function | |
}; | |
// The module init function | |
PyMODINIT_FUNC PyInit_mymodule(void) { | |
return PyModule_Create(&mymodule_module); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(gdb) bt
#0 __GI___mbrtowc (pwc=, s=, n=, ps=) at ./wcsmbs/mbrtowc.c:80
#1 0x00007ffff770b9b0 in _rl_insert_char () from /lib/aarch64-linux-gnu/libreadline.so.8
#2 0x00007ffff770c364 in rl_insert () from /lib/aarch64-linux-gnu/libreadline.so.8
#3 0x00007ffff76e89d0 in _rl_dispatch_subseq () from /lib/aarch64-linux-gnu/libreadline.so.8
#4 0x00007ffff76e8ebc in readline_internal_char () from /lib/aarch64-linux-gnu/libreadline.so.8
#5 0x00007ffff77091ec in rl_callback_read_char () from /lib/aarch64-linux-gnu/libreadline.so.8
#6 0x00007ffff77645f0 in readline_until_enter_or_signal (signal=, prompt=) at ./Modules/readline.c:1352
#7 call_readline (sys_stdin=, sys_stdout=, prompt=) at ./Modules/readline.c:1398
#8 0x00000000004248b0 in PyOS_Readline (sys_stdin=0x7ffff7e60920 <IO_2_1_stdin>, sys_stdout=0x7ffff7e615c0 <IO_2_1_stdout>, prompt=0x7ffff79c7560 ">>> ") at ../Parser/myreadline.c:392
#9 0x00000000004b8f08 in tok_underflow_interactive (tok=0xc1d330) at ../Parser/tokenizer.c:880
#10 tok_nextc (tok=0xc1d330) at ../Parser/tokenizer.c:1064
#11 0x00000000004a8238 in tok_get (tok=0xc1d330, p_start=0x7fffffffea68, p_end=0x7fffffffea60) at ../Parser/tokenizer.c:1419
#12 0x00000000004a622c in _PyTokenizer_Get (p_end=0x7fffffffea60, p_start=0x7fffffffea68, tok=0xc1d330) at ../Parser/tokenizer.c:2121
#13 _PyPegen_fill_token (p=0x7ffff796c490) at ../Parser/pegen.c:213
#14 0x00000000005dc39c in statement_newline_rule (p=0x7ffff796c490) at ../Parser/parser.c:1407
#15 interactive_rule (p=0x7ffff796c490) at ../Parser/parser.c:1108
#16 _PyPegen_parse (p=p@entry=0x7ffff796c490) at ../Parser/parser.c:38924
#17 0x00000000005dbd84 in _PyPegen_run_parser (p=0x7ffff796c490) at ../Parser/pegen.c:837
#18 0x0000000000606f7c in _PyPegen_run_parser_from_file_pointer (arena=0x7ffff78ef7b0, errcode=0x7fffffffebec, flags=0x7fffffffed30, ps2=0x7ffff79c75e0 "... ", ps1=, enc=0x7ffff79c60e0 "utf-8",
filename_ob=, start_rule=256, fp=) at ../Parser/pegen.c:910
#19 _PyParser_ASTFromFile (fp=, filename_ob=, enc=0x7ffff79c60e0 "utf-8", mode=256, ps1=, ps2=0x7ffff79c75e0 "... ", flags=0x7fffffffed30, errcode=0x7fffffffebec, arena=0x7ffff78ef7b0)
at ../Parser/peg_api.c:26
#20 0x0000000000426d84 in PyRun_InteractiveOneObjectEx (fp=fp@entry=0x7ffff7e60920 <IO_2_1_stdin>, filename=filename@entry='', flags=flags@entry=0x7fffffffed30) at ../Python/pythonrun.c:241
#21 0x0000000000426ae0 in _PyRun_InteractiveLoopObject (fp=0x7ffff7e60920 <IO_2_1_stdin>, filename='', flags=0x7fffffffed30) at ../Python/pythonrun.c:138
#22 0x00000000006067f4 in _PyRun_AnyFileObject (fp=fp@entry=0x7ffff7e60920 <IO_2_1_stdin>, filename=filename@entry='', closeit=closeit@entry=0, flags=flags@entry=0x7fffffffed30) at ../Python/pythonrun.c:73
#23 0x0000000000421f70 in PyRun_AnyFileExFlags (fp=0x7ffff7e60920 <IO_2_1_stdin>, filename=, closeit=0, flags=0x7fffffffed30) at ../Python/pythonrun.c:105
#24 0x0000000000605004 in pymain_run_stdin (config=0xa44f98 <_PyRuntime+59920>) at ../Modules/main.c:509
#25 pymain_run_python (exitcode=0x7fffffffed04) at ../Modules/main.c:604
#26 Py_RunMain () at ../Modules/main.c:680
#27 0x00000000005ce814 in Py_BytesMain (argc=, argv=) at ../Modules/main.c:734
#28 0x00007ffff7ce7740 in __libc_start_call_main (main=main@entry=0x5ce6b4 <_start+52>, argc=argc@entry=1, argv=argv@entry=0x7fffffffef58) at ../sysdeps/nptl/libc_start_call_main.h:58
#29 0x00007ffff7ce7818 in __libc_start_main_impl (main=0x5ce6b4 <_start+52>, argc=1, argv=0x7fffffffef58, init=, fini=, rtld_fini=, stack_end=) at ../csu/libc-start.c:360
#30 0x00000000005ce6b0 in _start ()
(gdb)