Structy generates code by reading a schema written using Python syntax:
In vs Out (c):
Note that I said "Python syntax" not Python. I'm just using Python's parser to generate an AST and just reading that to generate the code.
To pack and unpack the struct, the generated code uses a lightweight library based on Python's "struct" library. It uses format specifiers to pack stuff in. Think printf for binary data:
Since it knows about types, it can also generate a nice debug print function for the struct. It even handles the custom "fix16_t" type.
Oh yeah I got Python generation kind of working too.
I still got a bit to do before I release this to the world. But you might be asking why I'm doing this instead of using .... anything else.
The reason is that I like to keep my firmware super small and super simple. Protobuf & friends just... are too much.
Structy is made to replace some C code in my firmware that looks like this:
Everytime I added or updated a field for that struct I'd have to update this function, the matching serialization function, and the Python & JavaScript versions! That's like... 6 places I have to update! Ugh. (python code pictured)
It's fragile and annoying, but protobuf & friends are *overkill*. I just need to pass some dumb structs with scalar fields.
Hence, structy.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Lmfao how am I ever supposed to get well enough to return to my job?
I know y'all see me posting stuff and are probably confused as to why I'm not able to work right now. It's because I'm mentally ill. The creative stuff I do outside of work- like electronics and neat blog posts- are mechanisms for me to regain my abilities.
But they're hard. Focusing is all or nothing for me- I either can not focus at all or I laser focus on something to the point where I don't eat, sleep, or anything. Starting and finishing creative tasks is incredibly difficult and inconsistent for me.
You stupid motherfuckers are about 4 years late. Y'all are complicit. You gave him a platform- a megaphone. You encouraged him. You made money from him.
You only give a fuck now because he can't retaliate anymore.
Don't even pretend otherwise. Your Safety team routinely suspends the accounts of trans people for no god damn reason. Trump should've been banned ages ago but your leadership has protected him for FOUR YEARS.
Fuck you, Twitter Safety & Leadership. I don't feel any more safe.
"After close review". Your review took four years? Four years?! Hundreds of thousands of people dead because of this demagogue and you let it happen for *years*.
I hope to high hell that that the new administration seeks to heavily regulate Twitter & Facebook.
I've been throwing myself at making a tiny c library a beautiful polished rock because I've been outright avoiding processing anything that's happening in my life.
Why would I try to deal with my crushing loneliness and anxiety when I could enable another esoteric compiler warning and make sure my 300 lines of code doesn't upset software daddy?
Why try to figure out how the hell I'm supposed to go back to work when I could read through the disassembly of switch statement?
I'm taking apart my KeyStep for $REASONS, so here's a thread of interesting things I've found!
🧵
First up is the brains of the operation: an STM32F103. Not a lightweight chip: It's a Cortex M3 @ 72MHz. It's got 256kB of flash and 48kB of RAM and that's a 100-pin TQFP package!
The KeyStep has a 9V power input so I wanted to see what voltage regulator it uses - no surprises here, it's the tried and true LD1117. Nice heatsink design.
I once raised an issue with a SVP of marketing for only highlighting a single cis male drag queen instead of the incredible accomplishments of a multitude of LGBTQ women.
Nothing fucking happened. He got the whole spotlight, we got the bullshit excuses.
If you're a trans woman reading this: It's complicated and nuanced and my take wasn't so much about people in the trans community but just cis people in general thinking that it's this universally affirming thing for trans women.
There's a reason we tend to use these filler words - it's a natural partner of human speech. They appear in every natural language. The serve an important linguistic purpose.
The biggest is that in conversations they indicate that the current speaker isn't done with a thought, so that other people int he conversation don't interrupt. Of course, when on stage it's a one side conversation. But- this isn't the only purpose.