FX-30, GPS and PIC32

Hello,
In my project, I use the FX-30 as ethernet router to 3G to transmit measurement data from my PIC32MZ microcontroller from microchip to a server.
The FX-30 has a GPS module. I can correctly get it to work via the command (gnss get loc3d, …).

However, for my application on my PIC32MZ, I need to have GPS coordinates. Currently, I use a GPS module communicating in RX / TX with my PIC32MZ.

I would like to be able to use the FX-30’s GPS to transfer data to my PIC32MZ via ethernet link.

Do you have an idea of how to proceed?

Thank you very much for your future response

how about ssh login to FX-30 via ethernet link?
After that you can enter AT command to get the GPS data.

Hiya,

Don’t forget to enable the SSH port in the firewall on the ethernet link…

ciao, Dave

If the SSH link is a bit too complex for the PIC32, you can also create a Legato application that would provide a simple UDP or TCP service, so that if you do a request to :3000 (random port number, can be 12345 if you want, doesn’t matter), the service would reply with a simple structure that contains the GPS coordinates.

You can also create a HTTP service that returns the GPS coordinates as a JSON structure, and parse the structure from the PIC32.

If you don’t mind the static coupling and you have a proper networking stack on the PIC32, the tcp service way might be simplest.

Thank you for your answers.
However, my microcontroller is not equipped with an encryption library for SSH.

Alternatively, implement Modbus communication via ethernet by running a passive program on the FX-30.

Hiya,

yeah, ssh might be a bit heavy for the PIC32.

As @CoRfr suggests. you’re probably best off building a Legato application that bridges the GNSS data to a simple protocol that the PIC32 can access over a simple socket. You’ll need to use the GNSS api to get the GNSS data, and have a look at this socket tutorial or even Beej’s Guide if you’re not familiar with linux network socket programming.

ciao, Dave

Thank you for your answer. I will tackle this solution. I’ll let you know and I’ll try to leave some traces on the subject.

Hi @valentin_pl,
did you try the suggested solution?
is it solved your issue?
best regards,

Yes I found a solution.
I will use a TCPIP socket server.
The FX-30 will play the role of a server and when the PIC32 (client) sends him a request, he will answer with his Socket the GPS information.
For the moment I have not done the code yet, I put that aside.
There I just installed Developer Studio however I am block with the “Docker” … impossible to program my FX-30, …

Small question @davidc, does the package for FX-30 has libraries to access the function “le_gnss_Start ()”, “le_gnss_GetLocation ()” because I can not find them? Unless there is a manipulation to be done? Thank you for helping me, I have many things to learn yet!
Regarding the TCP / IP socket server, I managed to implement it and communicate with the PIC32.

Hiya @valentin_pl

Yep, all the le_gnxxXXX functions are supported on the FX30/WP8548.

You should be doing all this in legato to make sure that everything is set up and linked correctly.

To access the le_gnss functions, you need to do three things:

In your component Component.cdef file:

requires:
{
    api:
    {
        le_gnss.api
    }
}

in your application application.adef file:

bindings:
{
    application.component.le_gnss -> positioningService.le_gnss
}

and finally in each of your source files

#include "legato.h"
#include "interfaces.h"

Hope this helps.

ciao, Dave

Thank you for your answer @davidc .
I understood that there was a story of .api however I did not manage to use them.
And precisely, I still have an error in the bindings, I quote my code of server.adef:

sandboxed : false

bindings {application.component.le_gnss -> positioningService.le_gnss }

executables:{ serversoc = (serverComponent) }

processes : { run { (serversoc} }

And during the build, I got the error: "server.adef: 5: 4: error: Executable ‘application’ not defined in application.

I can not find what is missing despite my readings on Legato’s docs.

Thanks :slight_smile:

Edit : In the bindings, it’s not "application.component … but serversoc.serverComponent…

Every second, I call the function “gestion_gnss” so that it generates a new buffer for sending a GPS frame to the microcontroller who is the client.

However each time I call for example the function le_pos_GetTime, I always have the same values, it does not update.
I did not really understand how we manage the update days … Should we use an event handler?

Here is my code:


uint16_t gestion_gnss()
{
state_gnss=le_gnss_GetTtff(&ttff);
//LE_INFO(“TTFF: %d”,ttff);

if(state_gnss == LE_NOT_PERMITTED)  // LE_NOT_PERMITTED If the GNSS device is not enabled or not started.
{
	LE_INFO("Not enabled/start");
	le_gnss_Enable();
	if(le_gnss_Start()==LE_OK) state_gnss= LE_NOT_PERMITTED;
	else {
		memset(buffer_gnss,0,sizeof(buffer_gnss)); // RAZ chaine de caractère
		sprintf(buffer_gnss,"DONTSTART\n;");
		return false;
	}
}


if(state_gnss == LE_BUSY) // LE_BUSY The position is not fixed and TTFF can't be measured.
	{
	LE_INFO("BUSY");
	memset(buffer_gnss,0,sizeof(buffer_gnss)); // RAZ chaine de caractère
	sprintf(buffer_gnss,"GNSSBUSY;\n");
	return false;
	}


if(state_gnss == LE_OK)  // - LE_OK  Function succeeded.

	{	//LE_INFO("OK");
		state_gnss=0;
		le_pos_Get3DLocation(&latitude,&longitude,&hAccuracy,&altitude,&vAccuracy);
		le_pos_GetDate(&yearPtr,&monthPtr,&dayPtr);
		le_pos_GetTime(&hours,&minutes,&seconds,&milliseconds);

		memset(buffer_gnss,0,sizeof(buffer_gnss)); // RAZ chaine de caractère
		sprintf(buffer_gnss,"%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;\n",numTrame,latitude,longitude,hAccuracy,altitude,vAccuracy,yearPtr,monthPtr,dayPtr,hours,minutes,seconds,milliseconds);
		LE_INFO("New trame");
		LE_INFO("%s",buffer_gnss);
		numTrame++;
		return true;
	}

return false;

}