Blog time!
It's only been 7 days and 27 minutes since my last blog post (yup, it's 1AM again), but I've got plenty of material.
First of all, I did manage to fix the subprocess issue that was bugging me for 3 days; like this:
so it basically closes down and reopens the PIPE every loop (I guess forcing the stdin and stdout, because ParseSerial.communicate() closes the IO and gives a bunch of fun errors).
But in the end, I didn't end up using it. I realized how I don't really need much receiver-side parsing, because I can just send already easily-interpretable data from the rocket. So I switched to putting the received data into a .JSON file and reading from that.
Speaking of JSON, I added a config tab in the GUI, where you can set API key, COM channel, baud rate, and refresh frequency, so it doesn't require you to change the JSON manually or go digging around in the code and rebuild it (eww) and you can change it during runtime.
I also now have a button that you press to start sampling, and it calls all scripts needed to keep the data updated. Though this was a bit tricky, because, for the JS scripts, I first tried using await Neutralino.os.execCommand(`node ${pathtoscript}`) , which didn't work because node doesn't recognize Neutralino commands (like await Neutralino.init() ), so I looked it up and got some info from Stackoverflow to import the JS script I want to run and call it as a function. And that worked. I also needed to call a python script to get the actual serial data, which I also did with
await Neutralino.os.execCommand(`python &{pythonpath}`) . For a while this didn't work (even when called with 'python3'), until it did. I'm not sure what I did, but the errors went away and it can call, it now but what's weird is that I got completely different errors when running with python or python3.
Then I noticed a big issue. When you build the app with 'neu build', it puts spews out a .exe and a resources.neu. But so far I got the paths to the Json, JS and python files by getting the absolute path and then adding "./SerialRead.py" to the end, or something along the lines. But because there are no more 'independent' files after building, you can't find the path, let alone call it, because its all in resources.neu. So I tried using the built-in NL_PATH command, which you would THINK would work because its meant for this, but it gives a single dot as path. Because of this, Instead decided to put the built app, resources.neu in a folder, along with two JSON files with the same name. Now, when editing the code, it checks whether a variable called 'const build' is set to true or false. If it's set to false, it uses the default path through the ./resources folder (so you can do 'neu run'), but if set to true, it uses the exposed json files in the folder (for the built app). I also did this with the python script, because that's not in the resources.neu file either.
I also got the RPi CM5 finally! Along with the IO board. I was really looking forward to it, because it's literally a mini PC running linux, but needless to say for 4 days I thought it was broken on arrival because I didn't know you had to attach it to the IO board with force, not just place it on there. Obvious in retrospect, but I didn't want to break it. Anyways, I'm gonna have to cancel that replacement request...
So far, it's what you'd expect; awesome af, but I haven't done much with it yet, because I haven't gotten around to making a 5V-->3.3V level shifter for UART so I can actually try and read some input without having to buy magic smoke refill.
Back to the SerialRead.py; as I mentioned, I'm not using pipes or subprocess, but changing a json file constantly. Which works, but the JS file supposed to read and display the values can't read it. And I don't get it, because the writing time of python and reading period of JS does definitely not overlap, but especially not forever. It reads it once, then stops doing so (it's in an infinite loop). But if I disconnect the Serial-to-USB adapter, killing the python script, it stars updating again and displaying the newest data. I'm really not sure what to do about this, but I'll figure it out, maybe giving the json data directly to the JS script. I'll see.
Oh and I also got an ST-LINK V2 so now I can get to coding that finally. I'm really doing anything but resting in the winter break, but I love these projects so much, this one especially.
I'm pretty sure I had like 3 more things I wanted to share, but I can't remember, so bye now.
TTZ
Nincsenek megjegyzések:
Megjegyzés küldése