Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to assign IP address manually? #4

Open
ken551 opened this issue Jul 28, 2020 · 7 comments
Open

How to assign IP address manually? #4

ken551 opened this issue Jul 28, 2020 · 7 comments
Assignees

Comments

@ken551
Copy link
Contributor

ken551 commented Jul 28, 2020

Hello.
I'm very interested in this project and trying to run this example app on stm32.

I managed to build both the Linux program (on Ubuntu 18) and the stm program.
However, they didn't start communication.

I couldn't understand what I have to do with the step3 "Manually assign an IP address (and subnet mask) to the STM32."
I tried some methods ( code generation from cubeMX, DHCP with the router, etc.) but none of them worked.

Could you tell me how to set the IP address manually?
Or, would you tell me if there's some other solution?

Thank you.

@akampmann
Copy link
Contributor

Hi ken551,

thank you for reporting this. That is a mistake in the Readme. You have to manually assign an IP address to your Ubuntu machine (for example: IP:192.168.0.1, subnet: 255.255.255.0), not the STM32 (the STM32 default IP address is 192.168.0.47).

Can you please try that and come back to me?

Best regards
Alex

@akampmann akampmann self-assigned this Aug 10, 2020
@ken551
Copy link
Contributor Author

ken551 commented Aug 11, 2020

Hello, Alex.

Thank you for your comment.
I assigned static IP to my Ubuntu PC and tried again, but my PC and STM32 didn't start communication.
the embedded_rtps_testexecutable output the following

Creating RTPS Participant...
Creating Participant...
Created Participant succesfully.
Creating RTPS reader on topic:TOLINUX
Creating FastRTPS Writer on topic TOSTM
Successfully created writer.
Waiting for reader match with STM32...

and nothing happened after that

With tcpdump, I found that the PC got the following packets from the STM.:
(uden-CF-SX3TDLTC is the linux PC and has IP 192.168.11.3. STM has IP 192.168.11.7. I changed the IP assigned to the STM by changing config.h, lwipcfg.h, and lwip.c )

00:05:22.566987 IP 192.168.11.7.7400 > 239.255.0.1.7400: UDP, length 204
	0x0000:  4500 00e8 00e1 0000 ff11 fe73 c0a8 0b07  E..........s....
	0x0010:  efff 0001 1ce8 1ce8 00d4 4f33 5254 5053  ..........O3RTPS
	0x0020:  0202 0d25 0102 0304 0506 0708 090a 0c00  ...%............
	0x0030:  0901 0800 0f01 0000 0000 0000 1505 a800  ................
	0x0040:  0000 1000 0001 00c7 0001 00c2 0000 0000  ................
	0x0050:  0100 0000 0003 0000 1500 0400 0202 0000  ................
	0x0060:  1600 0400 0d25 0000 3100 1800 0100 0000  .....%..1.......
	0x0070:  f31c 0000 0000 0000 0000 0000 0000 0000  ................
	0x0080:  c0a8 002f 3200 1800 0100 0000 f21c 0000  .../2...........
	0x0090:  0000 0000 0000 0000 0000 0000 c0a8 002f  .............../
	0x00a0:  3300 1800 0100 0000 e81c 0000 0000 0000  3...............
	0x00b0:  0000 0000 0000 0000 efff 0001 0200 0800  ................
	0x00c0:  6400 0000 0000 0000 5000 1000 0102 0304  d.......P.......
	0x00d0:  0506 0708 090a 0c00 0000 01c1 5800 0400  ............X...
	0x00e0:  3f00 0000 0100 0000                      ?.......
00:05:24.565035 IP 192.168.11.7.7410 > uden-CF-SX3TDLTC.7412: UDP, length 52
	0x0000:  4500 0050 00e2 0000 ff11 2360 c0a8 0b07  E..P......#`....
	0x0010:  c0a8 0b03 1cf2 1cf4 003c fdbd 5254 5053  .........<..RTPS
	0x0020:  0202 0d25 0102 0304 0506 0708 090a 0c00  ...%............
	0x0030:  0701 1c00 0000 03c7 0000 03c2 0000 0000  ................
	0x0040:  0100 0000 0000 0000 0100 0000 2d00 0000  ............-...

I also confiemed that

  • ping to STM worked and the mac adderss of stm (00:80:e1:00:00:00) could be found on arp table shown with arp -a
  • firewall is disabled with ufw disable command
  • Fast-RTPS submodule is on commit af648ac
    (and I also installed Fast-RTPS v1.8.0 manually and tried with other program with the same topic name, but it didn't work either.)

Could you let me know if there are any solutions?
Thank you.

@akampmann
Copy link
Contributor

Hi ken551,

Ive been on leave and will be back in the office tomorrow. I will look into this and come back to you. Could you provide a Wireshark recording?

Best regards
Alex

@ken551
Copy link
Contributor Author

ken551 commented Aug 24, 2020

Hello, Alex.

Thank you for your reply.

As you told, I upload the wireshark recording.
rtps_capture.zip

the stm has address 192.168.11.7, and the host PC has address 192.168.11.3.

When capturing packets, first I launched the stm32 app, then I started capturing, and finally I executed the linux participant.
I turned off Wi-Fi, and before launching wireshark I confirmed that ping to the stm board responded.

Thank you.

@akampmann
Copy link
Contributor

Hi ken551,

I don't have access to an STM32 just yet but I spotted (at least one) problem in your setup. embeddedRTPS still uses the default IP address (192.168.0.47) as its Unicast locator during participant discovery, but the actual IP address of the STM is 192.168.11.7. Participant discovery will not work this way, as the Ubuntu machine will try to contact the STM using the wrong IP address.

Screenshot 2020-08-24 at 18 30 34

Can you please double check if you changed the IP address in include/rtps/config.h to 192.168.11.7?

const std::array<uint8_t, 4> IP_ADDRESS = {192,168,11,7};

If this is the case, could you please try to checkout the code again and use 192.168.0.1 as the IP address for the Ubuntu machine?

Best regards
Alex

@ken551
Copy link
Contributor Author

ken551 commented Aug 25, 2020

Hello, Alex.

As you told me, I set back the IP on the STM and the PC to the default value (192.168.0.47 and 192.168.0.1), and then it worked perfectly!

However, when I checked the files before that, the IP addr was ceertainly set to 192.168.11.7 as follows:

config.h (copied from config_stm.h) L35~

    namespace Config {
        const VendorId_t VENDOR_ID = {13, 37};
        const std::array<uint8_t, 4> IP_ADDRESS = {192,168,11,7};  // Needs to be set in lwipcfg.h too.
        const GuidPrefix_t BASE_GUID_PREFIX{1,2,3,4,5,6,7,8,9,10,12};

lwipcfg.h L23~

#define LWIP_PORT_INIT_IPADDR(addr)   IP4_ADDR((addr), 192,168,11,7)
#define LWIP_PORT_INIT_GW(addr)       IP4_ADDR((addr), 192,168,11,1)
#define LWIP_PORT_INIT_NETMASK(addr)  IP4_ADDR((addr), 255,255,255,0)

lwip.c L55~

void MX_LWIP_Init(void)
{
  /* IP addresses initialization */
  IP_ADDRESS[0] = 192;
  IP_ADDRESS[1] = 168;
  IP_ADDRESS[2] = 11;
  IP_ADDRESS[3] = 7;
  NETMASK_ADDRESS[0] = 255;
  NETMASK_ADDRESS[1] = 255;
  NETMASK_ADDRESS[2] = 255;
  NETMASK_ADDRESS[3] = 0;
  GATEWAY_ADDRESS[0] = 192;
  GATEWAY_ADDRESS[1] = 168;
  GATEWAY_ADDRESS[2] = 0;
  GATEWAY_ADDRESS[3] = 1;

I also found that the IP addr specified in embedded_rtps_stm32.ioc file was 192.168.0.47.
Therefore I opened the .ioc file by cubeIDE, changed the value, re-generated codes, and compiled them.
In this case, the compilation failed.
Could you let me know any other solutions to change the IP adderss assigned to the STM if there are?

Thank you.

@takasehideki
Copy link
Contributor

According to my observation, lwipcfg.h is not used for STM32.
Here is the only location to include lwipcfg.h and is not enabled.
https://github.com/embedded-software-laboratory/embeddedRTPS/blob/dc5e5106b136e91fad54dc969f3a4d68ea101566/src/rtps.cpp#L37-L45

So the files that need to be modified for IP assignment are config.h and lwip.c. I guess the comment in config_stm.h is wrong. I fixed this description in embedded-software-laboratory/embeddedRTPS@39d18c7 and sent it in embedded-software-laboratory/embeddedRTPS#3

My opinion is this issue has been fixed! and could be closed :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants