PostFrontal Forum
PostFrontal Forum
LK8000_Support_Forum | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 LK8000 International Support
 Developers
 Accessing comport from code
 New Topic  Reply to Topic
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

sundancer
Pulcino

Czech Republic
41 Posts

Posted - 17/03/2015 :  12:58:12  Show Profile  Reply with Quote
Helo
I got stucked on IO problem. The task I am trying to do is to make a special build for my home made instrument (KOBO + arduino board). I want to implement special sound alarms. My idea is to modify PlayResource function in sound.cpp to send special string code to Kobo com port (this is already in device setup). The external device will then play the sound.

Can anyone give me some hint about this?

I read that there is IRC chanel, but there is noone. Is there also a skype channel? Are there some developers active?

Coolwind
Moderator

Italy
8957 Posts

Posted - 26/03/2015 :  01:47:05  Show Profile  Visit Coolwind's Homepage  Reply with Quote
What kind of hints do you need ?
As you say, you need to change the sound function, and nothing else is needed.
It depends on how your hardware is seen by linux. I hope you dont need to develop a device driver yourself, that's not something related strictly to LK..
Go to Top of Page

sundancer
Pulcino

Czech Republic
41 Posts

Posted - 26/03/2015 :  10:53:14  Show Profile  Reply with Quote
I need to:
Access com port which is set in the device setting and send string to the device. Thats all.
Go to Top of Page

brunotl
Pterodattilo

France
1154 Posts

Posted - 26/03/2015 :  11:07:33  Show Profile  Reply with Quote
find "d->Com->WriteString" and you will found lot of exemple ...
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 26/03/2015 :  11:50:48  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
Well, in fact I'm actually doing exactly the same thing for the GoFlyV4!
I discuss with Bruno, and the correct and clean way to do it is to make a new driver. With this method, you change nothing on LK, just add a driver than can be use for the devices who want it.
I'm actually blocked because Jarek who manage the GoFLy is not available for now, and it seems the GoFly doesn't understand the NMEA sentences I sent to the device. But the mechanism is ok and seems to works.
I think the definitive sentences we will choose for the Gofly, will be to send the name of the sound file. So if you choose to implement the same sentences in your arduino board, you can use the GoFly driver I make, without doing anything!
I can make public my actual development branch for that if you are interested. I still have some work to do on it, but you can have a good idea on how it works, and make some tests.

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page

sundancer
Pulcino

Czech Republic
41 Posts

Posted - 26/03/2015 :  12:46:12  Show Profile  Reply with Quote
Making a driver is a nice idea, but I really dont to make my device dependent on GOFLY code. I will make my device for my frineds and they will surely want to have version updates. If there are uncompatible changes in your driver, I will have to repair it for them.

The other way I was thinking is the XCI events.
There is direct possibility to post event = SendNMEAPort1 ANYDATA
But I dont know if there is an airspace warning. But this would be a very nice solution (but I dont know if this works for LK8000. It works for xcsoar)

If you share the code I will be glad.
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 26/03/2015 :  12:51:20  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
Yes you can make another device for you, based on the gofly one. There will be very few code to make.
I will check if my code is still usable, and I will share it.

I tell you here when it's done. Hope I can do it today.

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 26/03/2015 :  13:37:34  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
Check this commit: https://github.com/jaaaaf/LK8000/commit/638c0fe9742ecbaac0257ee5565c66a6e0b6a73c
Hope it works, I'm not very strong with git...

You just have to do the same thing as devGoFlyV4.cpp and devGoFlyV4.h, and implement as you want the method : DevGoFlyV4::SendAlarm(PDeviceDescriptor_t d, int alarmId )

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page

Coolwind
Moderator

Italy
8957 Posts

Posted - 26/03/2015 :  17:32:19  Show Profile  Visit Coolwind's Homepage  Reply with Quote
Can you provide an example of what you need to send to the device through the com port?
Because if it is something short, you dont need to do anything special through com ports, you simply access the device itself from the code.

If I am not wrong, all you want is to write something like GPFALARM,1 to the device.
The easy way: open the device and write to it, then close it.
To make it async, write to a named pipe, or to a message queue, and have a separate standalone (out of LK) little program that read the pipe or message queue and writes to device.

The most complicated way: create a device in LK for a simple operation like that..
The device name can be a link to the real one, so even if you change real device, the link is always available.

Where is the problem to do so?

Edited by - Coolwind on 26/03/2015 17:37:51
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 27/03/2015 :  22:17:38  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
Yes, you can do like Coolwind said. But you need to put your code everywhere you want to write sounds.

If you want to do it in my way, I update my code in a most complete commit here: https://github.com/jaaaaf/LK8000/commit/86cdb5b2a0741ccdbab9f02b0fb9e5367a3488aa
(come modifications was missing to works in the last commit I made)

Still not working for now on my GoFly, but nmea strings are sent.

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page

Coolwind
Moderator

Italy
8957 Posts

Posted - 27/03/2015 :  22:51:29  Show Profile  Visit Coolwind's Homepage  Reply with Quote
you too have to change the code if you want to use more than 1 sound (GFPALARM,1) .
For me it is a complicated way of doing a simple work, but for fun anything is possible of course.
Go to Top of Page

brunotl
Pterodattilo

France
1154 Posts

Posted - 28/03/2015 :  15:12:54  Show Profile  Reply with Quote
i think way used by jaaaf, is the best for avoid side effect.
Go to Top of Page

parapenT1sta
Pterodattilo

Portugal
1864 Posts

Posted - 28/03/2015 :  15:17:29  Show Profile  Visit parapenT1sta's Homepage  Click to see parapenT1sta's MSN Messenger address  Reply with Quote
Bruno, can you merge the Jaaaf code to your branch? I think a lot pilots with V4 would like to test it.
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 28/03/2015 :  15:19:47  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
It's not a good idea to take it now like this.
For now it doesn't work on my device, and it's not finished! Actually all sounds will be the same (if there is any sounds).

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page

Coolwind
Moderator

Italy
8957 Posts

Posted - 28/03/2015 :  16:33:58  Show Profile  Visit Coolwind's Homepage  Reply with Quote
Exactly. And I am quite curious to know how you are going to make different sound in the source code without changing it.
I have already told what was the correct approach to do this, and not to create a device in LK for a simple playsound, so I wait to see what comes next.
Go to Top of Page

jaaaaf
Pulcino

France
81 Posts

Posted - 29/03/2015 :  11:44:45  Show Profile  Visit jaaaaf's Homepage  Reply with Quote
Coolwind, it's easy, like I said before, just implement the method DevGoFlyV4::SendAlarm(PDeviceDescriptor_t d, int alarmId )
You can make a conversion table, or you can just send the alarm id you receive, if your sending device know how to interpret it.
With the conversion table, you can make a conversion for sound you really want to be different, and default sounds for others.

This method has also the advantage to have only one build for different devices receiving NMEA sentences. You just have to change the device used on LK config, on your device.

Jack, competition paragliding pilot _LK8000 on V2, V3, V4, ..._
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
Jump To:
PostFrontal Forum © PostFrontal - La community del Volo a Vela Go To Top Of Page
This page was generated in 0.16 seconds. Snitz Forums 2000

Since 2006, owned and maintained by PostFrontal S.A.S. di Giuliano Golfieri & c. - VAT ID: IT05264240960
THIS WEBSITE ONLY USES FUNCTIONAL COOKIES
Privacy & Cookie Policy