Serial plugin, questions

Questions regarding plugin development and publish plugins

Serial plugin, questions

Postby ogaland » Sun Apr 14, 2019 4:29 am

Hello,

I ordered my goverlay screen and i'm happy of this, it work like a charm, but I would like to monitor custom sensors.
I would need any advice to make the work easier, I posted in plugins sections, as I guess I must write a plugin for that.

Application is to display water temperature, and flow value on a dual-loop watercooled computer.
To be short the 4 customs sensors (2 temp and 2 waterflow) will be plugged to an arduino and communication with PC will be done using the COM port.
(simplest way I found to solve the issue as I can't directly plug the sensor on the motherboard)

For this I'm currently working on an arduino sketch, I'm currently able to display water temperature, and I'm working to read correctly water flow sensor.
I did a very basic interface on COM port which can return datas on releveant commands (which i can customize on will) :

Example : Send GET on COM port will return the sensors current values like : FLOWA:0.00|FLOWB:0.00|TEMPA:26.73|TEMPB:26.94

I did a quick look on current plugins and I guess it would be possible to make it work (hwinfo plugin seems to retrieve new sensors from an external application, this looks like close to what i want to do)

All I need would be to create a basic application on the PC that will query the arduino and provide data to the goverlay plugin.
But which method could I use ? Storing values in a file ? hwinfo plugin (I checked very quickly) seems to use a MemoryMappedFile (I don't know that), is it the good way of doing it ? any alternate way ?

Thanks for reading me.

Olivier,France
Last edited by ogaland on Sun Apr 21, 2019 4:29 am, edited 1 time in total.
ogaland
 
Posts: 3
Joined: Sun Apr 14, 2019 4:00 am

Re: Arduino plugin, questions

Postby ogaland » Mon Apr 15, 2019 3:31 am

Replying to myself after some work on that dev.

Looks like I missed the easy solution : do the COM connection inside the plugin. After reading plugin doc and checking a few example, it seems to work well. I can display the data gathered by the arduino on goverlay.

I will probably publish the result once I have sorted and cleaned my mess, I don't know if many people would have the same need.
ogaland
 
Posts: 3
Joined: Sun Apr 14, 2019 4:00 am

Re: Arduino plugin, questions

Postby TheLaGmAn » Wed Apr 17, 2019 1:04 pm

Yes, you can make a plugin and connect directly to the com port, that should work.
Other alternative is to make a separate windows application that would write to a .INI file and use goverlay to load the data from the file, but you would need this additional app to be running along with GOverlay, its better to use a plugin if you can make one.
If you will make it and pubish it, let me know if you get stuck with anything and i can give you a hand.
TheLaGmAn
Site Admin
 
Posts: 517
Joined: Wed Feb 26, 2014 8:32 pm

Re: Serial plugin, questions

Postby ogaland » Sun Apr 21, 2019 5:04 am

Hello TheLaGmAn

Thanks for your answer, I also saw you did the work on the HWInfo plugin, congrats as I use it to display my computer sensor (OpenHM unfortunately don't detect them) and I took lots of inspiration from it to write my plugin.

I created a github repository with the project, feel free to have a look and add any comment on change I could/should do. https://github.com/OlivierGaland/Octave
I'm partially satisfied with the result, the plugin option allow to choose COM port/speed/timeout, there is also an option to select refresh rate for the query/request on COM port (I was not sure It would handle 1 trx/sec).

My main questions are about how to deals with all the possible use case regarding the COM connection (cannot open at start, com connection temporarly loss during session, change plugins options) and as I never developped under VBnet I have no expertise on the possible solution.

I tried several use case like unplugging the arduino during use, changing options that need to restart the COM connection, and went for the following logic :

- Create the COM connection when AvailableSensors is called and keep the object (pluginsOptions available here)
- Check if connection need to be restarted (com port number change or speed change ...) in ... DisplayOnLCD (!) (as pluginsOptions is available here, I would have prefered to do it in Callback, but iI cannot grab pluginsOptions in this call)

I also need for each COM exchange to disconnect after to prevent error if I stop goverlay abruptly and restart it, or change options, so any COM exchange is enclosed in a Connect (that check is the connection is opened) then a Disconnect. (I don't like that but I din't find another way)

Here is currently the final result on LCDsys 3"5 (the arduino sensor are visible at the bottom (water temp -implemented- and water flow -pump are actually not running as the computer is currently under construction-)

Image
ogaland
 
Posts: 3
Joined: Sun Apr 14, 2019 4:00 am

Re: Serial plugin, questions

Postby TheLaGmAn » Wed Apr 24, 2019 12:22 am

Looks very good and thanks a lot for sharing.

You shouldnt need anything on the function "DisplayOnLCD" since its only called when the sensor is a custom draw one, and all sensors are not custom drawing.

On every run, if at least one sensor of your plugin will be used, the callback with "willrequestvalues" will be called, this is where you should connect/fetch values and save them into memory, and i see thats what you are doing so that logic is okay.
On the first run or every time the user gets into the profile tabs, goverlay will call "AvailableSensors" to get the current sensors, so you also should intiate the connection here, as you do.

- Create the COM connection when AvailableSensors is called and keep the object (pluginsOptions available here)

This is correct, before doing anything goverlay needs to know the available sensors so this will be the first thing called.

- Check if connection need to be restarted (com port number change or speed change ...) in ... DisplayOnLCD (!) (as pluginsOptions is available here, I would have prefered to do it in Callback, but iI cannot grab pluginsOptions in this call)

Uhm, DisplayOnLCD shouldnt be called, are you sure your code is getting here?


To access the plugin options anywhere where you dont have the pluginOptions variable, use

Dim optionSpeed = objHost.AccessHost("retrieve", "plugin_options", Name(), "speed")
Dim optionPort = objHost.AccessHost("retrieve", "plugin_options", Name(), "port")
It shouldnt affect performance but its best if you grab this data not too often (ex on every sensor request), so you dont call goverlay a lot of times for this, but doing it once per draw is probably okay
TheLaGmAn
Site Admin
 
Posts: 517
Joined: Wed Feb 26, 2014 8:32 pm


Return to Plugins Releases and Development



Who is online

Users browsing this forum: No registered users and 2 guests

cron