Closed Ulfasaar closed 6 years ago
Firstly, is sounds a bit like what you want is closer to the HL-C target than the hxcpp target - especially where the built-tool-free is concerned - but I think my comments are still valid.
Unfortunately, I think this will be tricky do do in some kind of meaningful way. This is mainly because the haxe object model is essentially pointer + class based, and micro controllers are usually static memory and main-loop based. I remember having in a brief discussion with Ian at the haxe conference about just this, and my conclusion was that although haxe is a nicer language than C in general, the C (and c++) on a micro-controller is actually pretty nice for getting the job done, since the job is usually quite linear.
That said, some code sharing would be nice - I'm just not sure what the effort to satisfaction ratio would be like. The trick would be to come up with a subset that can work - maybe add explicit "free" commands to all classes might solve the GC issue.
I don't want to discourage you too much, since any time working with the insides of something like this is time well spent.
Thanks for all the advice @hughsando :) . I see what you mean about the effort to satisfaction ratio. The plan is to start small at first and see what the difficulty of the project looks like since I am porting a lot of the other parts of my current project to haxe already, such as my server code. I am thinking of trying to get some very basic code working for the ESP32 or maybe an Arduino.
Also the difficulty doesn't worry me too much because I am looking for a nice hard problem to solve that could hopefully benefit the community in some way, and the university I work for.
The only other part of the masters work that was discussed was integrating some extra temperature sensors into the units we already made and I am unsure if that would be substantial enough for a thesis.
Hi. I really haven't look at this, but I wonder if something "higher level", similar to the HL/C approach, would be "Windows 10 IoT Core" based on UWP. UWP is working with NME (winrt target). I just mention it because it looks like much more "doable" but I have nill experience with iot.
You could progress this project by doing a "hand conversion" of what you are trying to achieve. For example, you probably do not want to do something like:
if (Reflect.hasField("x")) array.push(Refect.field("x"));
But maybe you want:
class Controller
{
static var counter;
public static function init()
{
counter = 0;
}
public static function loop()
{
if (Hardware.button1)
{
counter++;
Sys.println(counter);
}
}
public static function main()
{
init();
while(true)
loop();
}
}
And this would translate nicely to some embedded c code, and some things like properties and macros would work. So if you can write a kind of spec to keep the scope small, you should be able to get something going. A nice side effect of this would be that you could write an emulator for your hardware Api on the desktop, which could be useful.
Thank you guys for your suggestions and feedback :)
@madrazo, can you elaborate on your suggestion a bit more please? Are you suggesting to run windows 10 IOT core on the devices instead?
The issue with that if I am understanding correctly is that the devices I am planning on targeting usually only have about 32KB of storage for code, or a few megabytes if your lucky with later models.
For example here's the specs for the one Arduino we are using in production right now. https://store.arduino.cc/usa/arduino-pro-mini
So I am unsure if that would be able to fit windows 10 IOT core on it. That would be fine for something like a raspberry pi however that has a lot more storage. However I would still need to make extra code to access the pins on the device, since different pins are used for different things on each platform, and sometimes even between versions for the same board :D
@hughsando thank you for the great suggestions, that is exactly what I was aiming to achieve with the code. I suppose it would make it a lot easier to create emulators too like you said, which would be awesome because there have been several times that I wanted to test something, without having the hardware available.
Here is a link to the GitHub organization with all the code I've written for the project so far if anyone's interested. https://github.com/SKOMOBO
The Arduino repository in that organization contains the sort of code that I am hoping to generate with the new target.
can you elaborate on your suggestion a bit more please?
Sorry it was more a question than a suggestion. I see that you need more memory to work with UWP but in that case it is posible to use Linux as well
I'm closing this as an issue for hxcpp, but good luck with your projects.
Hi guys,
I think you are all doing a fantastic job. I have just recently thought of creating a fork of this repository to create a new target for haxe specifically for embedded and IOT systems.
At the moment the only changes I am considering doing are adjusting the generated code to make it more lean due to memory constraints and to try and reduce compiler time if possible.
I am also thinking of in this fork removing the awesome build tool you guys created in favor of allowing the user to use the compiler for their specific system, eg: they could use the AVR compiler for AVR chips, esp-idf for Esspressif chips etc.
The libraries for each board would be managed via extern libraries, since most only support one language or only have one that is really good.
Please note that the target would not be intended for raspberry pis, onion omegas etc that run a full operating system, for that I intend to make a haxe based framework for IOT devices instead.
There are a lot of existing systems that let you program for multiple platforms however most are restricted to one language, forcing you to program in c++ for instance if you want to program micro-controllers, and thus make it hard to share code with a server, mobile app etc.
The usual alternative is that the framework / platform would require a permanent connection to a full computer which would run the high level language and send basic commands to the circuit using Firmata or a similiar protocol.
However I want to share code between the server, apps, hardware etc whilst still being able to have things run offline, which the method described above should allow myself and others to do since haxe already has pretty good support for python, javascript, c++ etc.
I am going to chat with my supervisor for the project I am working on at the moment about maybe doing this as part of a masters thesis :)
What do you guys think?