lps node transmits data to PC by usb

All discussions related to the Loco Positioning system
Post Reply
Mathilda
Beginner
Posts: 6
Joined: Thu Jul 30, 2020 10:12 am

lps node transmits data to PC by usb

Post by Mathilda »

Hi!
I want to implement lps node as anchor and tag at the same time, but now I have some problems:
1. I have realized the communication between two crazyflies (crazyflie serves as anchor and node at the same time)
2. According to the logic in 1, I hope to realize the lps node as anchor and tag at the same time, but I have encountered some problems:
First, crazyflie initiates ranging and sends poll packet, lpsnode receives poll packet and returns an answer packet. The problem is:in the rxcallback() function on the crazyflie side, rxpacket.payload[0] = (unsigned int) 48, does not belong to [0x01,0x02,0x03,0x04], so it cannot enter the switch( ) .
here is the code in lpsnode,which is try to set the node as anchor and tag at the same time:https://paste.ubuntu.com/p/mC7D3ZQ7v2/
here is the code in crazyflie,which is try to deal with the packets from lpsnode(as anchor & tag):https://paste.ubuntu.com/p/zQJq2hBPhd/

So, I want to see if payload[0] is written to the lps node and to output some parameters on the lps node through the USB serial port.

I want to know if this can be achieved? Which part of the code is involved? Is it possible to modify the stm32 code directly?
arnaud
Bitcraze
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: lps node transmits data to PC by usb

Post by arnaud »

Hi,

This problem seems odd, I looked briefly at your node code and I would not expect payload[0] to ever be 48.

On the node side, it is quite easy to print on the usb uart, you can just use "printf()" as you would do on a PC. This will most likely affect timing but at least you should be able to print values on the way.

On other thing you might want to try is to setup another node in sniffer mode. This would allow you to see what is actually transmitted in the air.
Mathilda
Beginner
Posts: 6
Joined: Thu Jul 30, 2020 10:12 am

Re: lps node transmits data to PC by usb

Post by Mathilda »

Hi! Arnaud,
Thank you for your answer.
Actually,the payload[0] = 48 is what I printed in Console after received a packet from lps node. If the node received the correct packet, the crazyflie will receive the poll packet(payload[0] = 1) ,answer packet( payload[0] = 3) or report packet( payload[0] = 4) according to the modified protocol.
That`s why I want to print the packet infomation in the lps node side. I want to know if there are something wrong in the lpsnode side.
I connect the LPS node to the computer of windows system through USB. Does the PC need a serial assistant to receive printf information ?
Yours,
Mathilda.
arnaud
Bitcraze
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: lps node transmits data to PC by usb

Post by arnaud »

When you connect a node to a PC, the PC will see a serial port. You can use your favorite serial terminal to communicate with the node, any printf() in the node code, will be printed in the serial terminal.

On Linux the serial port will be "/dev/ttyACMx" with x being a number. Often it is "/dev/ttyACM0" is no other USB serial port are connected to your machine. On Windows it will appear as a regular serial port.
Mathilda
Beginner
Posts: 6
Joined: Thu Jul 30, 2020 10:12 am

Re: lps node transmits data to PC by usb

Post by Mathilda »

Hi! Arnaud,
Thank you for your replay!
I will try the solution you gave after I finishing my final exam.
Finally,Christmas is coming.
Merry Christmas~
Post Reply