u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
299 stars 87 forks source link

Assistance Requested for Configuring ubxlib for LEAN_R8 on Linux #210

Closed IssamSayyaf closed 5 months ago

IssamSayyaf commented 5 months ago

Hello,

I hope this message finds you well.

I am reaching out to seek your guidance on configuring the ubxlib library for use with the LEAN_R8 device on a Linux operating system. I have successfully cloned the repository and identified the specific components I need within the UBXLIB_FEATURES section of the linux.cmake file.

Following this, I executed the cmake command to configure the build environment and subsequently ran the test program, which performed as expected. However, my primary objective is to ensure that the compiled library is fully compatible with the LEAN_R8 device, which connects via USB and communicates using the Point-to-Point Protocol (PPP).

Could you please advise on the steps necessary to instruct the cmake build system to target the LEAN_R8 device specifically? My aim is to ensure seamless communication over USB with PPP protocol support. and if there are any examples of this.

I appreciate your time and look forward to your expert advice.

IssamSayyaf commented 4 months ago

Just was a curious question just to be sure. Thank you, I am working to modify my code. A huge thanks

RobMeades commented 4 months ago

Not that it won't be a problem of course, I just can't see one ;-). LENA-R8 is full of surprises :-).

IssamSayyaf commented 4 months ago

haha :) , I would like to ask a question, we are wondering, if we can connect the LENA R8 GNSS UART with another microcontroller Cortex-M4. The LTE will stay working on Linux, however, the GNSS connects it with Cortex-M. Is it possible, is it a good choice?

IssamSayyaf commented 4 months ago

I have followed the instructions, however, I can't open the device—the error is -8.

Opened device with return code -8.

returnCode = uDeviceOpen(&gDeviceCfg, &devHandle); uPortLog("Opened device with return code %d.\n", returnCode); uCellCfgSetGnssProfile(devHandle, U_CELL_CFG_GNSS_PROFILE_USB_AUX_UART, NULL);

RobMeades commented 4 months ago

Obviously you will need to debug this to find out what would cause U_ERROR_COMMON_PLATFORM.

IssamSayyaf commented 4 months ago

I moved to implement this example it works, but it looks like uses the same port for LTE, in I brought up the LTE, and then I tried to move to GNSS, Everything was good however, there is an error

+CME ERROR: Operation not supported AT+UGPS=1,15,127

+CME ERROR: Operation not supported AT+UGPS=1,15,127 .

I don't know if it is the right way to start, could you recommend an example to start developing it to make LENA work?

log_GNSS.txt gnss_code.txt

IssamSayyaf commented 4 months ago

I feel I am stuck, if you can help me I will be thankful

IssamSayyaf commented 4 months ago

without UART, use the same port I received message is not support, if you can guide me how can I make it run using UART I mean another port, I will be thankful

RobMeades commented 4 months ago

You can take that approach if you wish, but remember that it will not support "streamed" position from the GNSS device (i.e. none of the ubxlib location/GNSS APIs with Streamed in the name will work): calling uNetworkInterfaceUp() on the cellular device will indeed use the same transport as uDeviceOpen() created, either starting up CMUX to do so or, where CMUX is not supported [the LENA-R8 case], it will drop back to using AT+UGUBX commands, which are not able to support streamed position from the GNSS device (as AT commands only do "polled" kind of behaviours).

The reason you are getting "+CME ERROR: Operation not supported" is likely because of the GNSS system selection number used at the end of the AT+UGPS command: we set it to "all" and some GNSS-enabled-cellular modules then set all of the ones they support, ignoring ones they don't while other GNSS-enabled-cellular modules reject the number if it asks for GNSS system types that the GNSS chip inside the cellular module does not support. You can try setting U_CELL_LOC_GNSS_SYSTEM_TYPES to, say 3, for now, and see if that works.

IssamSayyaf commented 4 months ago

Now, it is working, without this error unsupporting, however, still have a problen. Unable bring the GNSS This my modification // NETWORK configuration for GNSS static const uNetworkCfgGnss_t gNetworkCfg = { .type = U_NETWORK_TYPE_GNSS, .moduleType = U_CELL_LOC_GNSS_SYSTEM_TYPES, .devicePinPwr = -1, // The pins of the cellular module that are connected .devicePinDataReady = -1 // to the GNSS chip's power and Data Ready lines };

log_GNSS.txt

RobMeades commented 4 months ago

Ah, yes, I forget LENA-R8 does support CMUX, so the ubxlib code will try to use it, LENA-R8 just doesn't support access to the built-in GNSS chip over CMUX. For this case you should do a clean build with U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY defined and that will force ubxlib to only use AT commands to talk to the GNSS chip built into the cellular module.

IssamSayyaf commented 4 months ago

And if I want to have streaming, what should I do where should I move?

Because this will work on trucks so, I think the streaming will be important. Maybe latter, I will think about streaming but now for this what do you think the problem.

RobMeades commented 4 months ago

If you want streamed GNSS position then, as indicated above, you will need to debug why you were getting U_ERROR_COMMON_PLATFORM when you tried to call uDeviceOpen() for the GNSS device on the auxiliary UART.

IssamSayyaf commented 4 months ago

okay I will check latter, for the streaming.

Regarding this U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY , I didn't understand it.

IssamSayyaf commented 4 months ago

Could you tell me what should I do for this "U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY"

RobMeades commented 4 months ago

I mean that you should do a clean build with the conditional compilation flag U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY defined for the build.

IssamSayyaf commented 4 months ago

Ah okay, got it. I will do it. Thank you very much

IssamSayyaf commented 4 months ago

I have an error :) cc: warning: U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY: linker input file unused because linking not done cc: error: U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY: linker input file not found: No such file or directory make[2]: [CMakeFiles/ubxlib.dir/build.make:76: CMakeFiles/ubxlib.dir/home/root/LTE/ubxlib/common/at_client/src/u_at_client.c.o] Error 1 make[2]: Deleting file 'CMakeFiles/ubxlib.dir/home/root/LTE/ubxlib/common/at_client/src/u_at_client.c.o' make[1]: [CMakeFiles/Makefile2:85: CMakeFiles/ubxlib.dir/all] Error 2 make: [Makefile:91: all] Error 2

RobMeades commented 4 months ago

"linker input file not found: No such file or directory" is not an error I have ever seen or heard of I'm afraid. I would guess that you are not specifying the conditional compilation flag to your toolchain correctly...?

IssamSayyaf commented 4 months ago

it is like this export U_FLAGS="-DU_CFG_PPP_ENABLE -DU_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 -DU U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY"

RobMeades commented 4 months ago

-DU U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY doesn't look right to me...?

IssamSayyaf commented 4 months ago

I think I fix it

IssamSayyaf commented 4 months ago

it is the same

U_CELL: initialising with enable power pin not connected, PWR_ON pin not connected and VInt pin not connected. AT

OK AT

OK U_CELL_PWR: powering on, module is already on. ATE0

OK AT+CMEE=2

OK AT+UDCONF=1,0

OK ATI9

02.00,A01.22

OK AT&C1

OK AT&D0

OK AT&K0

OK AT+UPSV=0

OK AT+UGPRF?

+UGPRF:2,0,""

OK AT+CFUN=4

OK U_PORT_PPP: listening for pppd on socket 127.0.0.1:5000. Opened cellular device with return code 0. Bringing up GNSS... U_PORT_PPP: pppd has connected to socket. AT+CMUX=0,0,,128

OK ATE0 ATE0

OK AT+CMEE=2

OK Unable to bring up GNSS! U_PORT_PPP: pppd has been disconnected from socket. U_PORT_PPP: no longer listening for pppd on socket. Done.

RobMeades commented 4 months ago

Are you sure that was a clean build?

IssamSayyaf commented 4 months ago

Yeah I removed the directory and mkdir new one, then I export then cmake, the make.

I will try again

RobMeades commented 4 months ago

You can see the code here:

https://github.com/u-blox/ubxlib/blob/a2d986e2944141176eedaee6dc4be87be7eea57b/common/network/src/u_network_private_gnss.c#L214-L262

If U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY is defined execution should never get to line 216. You can try putting a debug print there to see what is happening.

IssamSayyaf commented 4 months ago

I made like to told me U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY is not define

so it doesn't define the Flag this how I export

Are there any problem export U_FLAGS="-DU_CFG_PPP_ENABLE -DU_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 -U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY"

RobMeades commented 4 months ago

export U_FLAGS="-DU_CFG_PPP_ENABLE -DU_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 -U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY"

I think you are missing a D there.

IssamSayyaf commented 4 months ago

God! sorry for this stupid mistake.

Okay, it looks like is going on the right way, I still have a problem

'U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY is define U_CELL: initialising with enable power pin not connected, PWR_ON pin not connected and VInt pin not connected. AT

OK AT

OK U_CELL_PWR: powering on, module is already on. ATE0

OK AT+CMEE=2

OK AT+UDCONF=1,0

OK ATI9

02.00,A01.22

OK AT&C1

OK AT&D0

OK AT&K0

OK AT+UPSV=0

OK AT+UGPRF?

+UGPRF:2,0,""

OK AT+CFUN=4

OK U_PORT_PPP: listening for pppd on socket 127.0.0.1:5000. Opened cellular device with return code 0. Bringing up GNSS... Unable to bring up GNSS! U_PORT_PPP: no longer listening for pppd on socket. Done'

RobMeades commented 4 months ago

OK, so now you need to get into the flow of debug. Do you have a debugger in your setup or are you just planning to use debug prints? If the former then you can put a break-point here:

https://github.com/u-blox/ubxlib/blob/a2d986e2944141176eedaee6dc4be87be7eea57b/common/network/src/u_network_private_gnss.c#L339

...and from there step down into uGnssPwrOn() to see what is happening. If the latter then you can insert debug prints at that point and then within uGnssPwrOn() to find out the same thing.

Basically, get yourself set up for debugging and "do that thang", so to speak, as you would for any development.

IssamSayyaf commented 4 months ago

Okay Okay, I think it will be better to make a real debug, I will use gdb, and then I will let you know.

IssamSayyaf commented 3 months ago

Hello, I hope everything is fine

I had some Hw problem I have solved, currently I am able to receive NMEA message from the GNSS, the boudrate is 38400, however, I am trying to run one of your example, I am facing some problem, could you advice me which example and how can I use your framwork to receive and control with the GNSS, thank you very much.

It is connected on /dev/ttySTM2, however, I always, have a problem with framwork could you help me.

IssamSayyaf commented 3 months ago

issam_LTE.txt I am working on this, however I don't know what is the problem

RobMeades commented 3 months ago

Hi there: it is a bit difficult to know how to help without knowing what the problem is. Looking at the code you have attached, the field .pPrefix seems to be being initialised multiple times, which I'm surprised compiles:

            .pPrefix = "/dev/ttySTM", // Prefix for the device file   <<< THIS SEEMS CORRECT
        .baudRate = 38400, /* Use 0 to try all possible baud rates and find the correct one. */
            .pinTxd = U_CFG_APP_PIN_GNSS_TXD,  // Use -1 if on Zephyr or Linux or Windows
            .pinRxd = U_CFG_APP_PIN_GNSS_RXD,  // Use -1 if on Zephyr or Linux or Windows
            .pinCts = U_CFG_APP_PIN_GNSS_CTS,  // Use -1 if on Zephyr
            .pinRts = U_CFG_APP_PIN_GNSS_RTS,  // Use -1 if on Zephyr
            //  <<< .pPrefix seems to be being initalised again, to what seem to be incorrect values, below >>>
#ifdef U_CFG_APP_UART_PREFIX
            .pPrefix = U_PORT_STRINGIFY_QUOTED(U_CFG_APP_UART_PREFIX) // Relevant for Linux only
#else
            .pPrefix = NULL
#endif