# Ping 1D with Ping-python can't connect to Ping Viewer

**URL:** <https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355>\
**Category:** Ping Sonar Devices\
**Created:** [March 27, 2021, 2:22pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355 "2021-03-27T14:22:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielT](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DanielT](https://discuss.bluerobotics.com/u/DanielT)\
**Post date:** [March 27, 2021, 2:22pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/1 "2021-03-27T14:22:16Z")

</div>

I am running this on a Raspberry pi using the Ping-python library from your Github. I set the IP address of the pi to 192.168.2.2 and the computer’s to 192.168.2.1 to eliminate the possibility of that being the problem.

So I run the provided sample command _sudo python3 simplePingExample.py --device /dev/ttyUSB0 --udp 192.168.2.2:9090_. And it reads information from the sonar. But it does the same as the command _sudo python3 simplePingExample.py --device /dev/ttyUSB0_.

In the code, it stops at the first _if_ statement and skips the _udp_ option I added. To fix this, I added _and args.udp is None:_ to line 24 of the sample script so when there is not udp option, it works without udp. And when the udp option is specified, it goes to the _elif_ and does that code. You have to also add _myPing.connect\_serial(args.device, args.baudrate)_ to the elif so it reads from the sonar.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/0/097f1448643957b57bea5bf44c5f0c5b052aa185.png)

And when I start it now, it gives an error, which I think means it is trying to set up the udp connection.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/3/36b06f8d8e4112cece2c0537b073a2ead36b591e.png)

This is where I don’t know what to do. I can read the data directly from the terminal (without the udp option), but then there is no point in having the Ping Viewer application. Is there anything I can do?

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [March 29, 2021, 3:28pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/2 "2021-03-29T15:28:33Z")

</div>

The issue is that the UDP port is a a string, not a number.

do something like `myping.connect_udp(host, int(port))` and it should work.

---

<div class="post-metadata">

**Author:** ![DanielT](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DanielT](https://discuss.bluerobotics.com/u/DanielT)\
**Post date:** [March 29, 2021, 4:07pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/3 "2021-03-29T16:07:15Z")

</div>

I just reinstalled brping and run the command again and get this error:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/c/c3403718c091b840da2ad04b60048f332321cfd7.png)

---

<div class="post-metadata">

**Author:** ![DanielT](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DanielT](https://discuss.bluerobotics.com/u/DanielT)\
**Post date:** [March 29, 2021, 4:58pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/4 "2021-03-29T16:58:43Z")

</div>

And when I do _myping.connect\_udp(host, int(port))_, the ping can’t initialize.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/a/a100eaf167f3a02e6db7841b4a46288cf95fbcbc.png)  
(I have modified the code to ignore errors and continue with the script)

Code:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/2/2210f51cff010ca739e21fd237d6852a589ded57.png)

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [March 30, 2021, 1:08pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/5 "2021-03-30T13:08:53Z")

</div>

I think the issue is that Ping-viewer expects to find an UDP server (you trying to connect to ping-viewer as if it was the server, while in reality, your code should be it).  
Check the code of [Ping-proxy](https://github.com/bluerobotics/ping-python/blob/master/tools/pingproxy.py). You should bind to a port and wait for a connection.

---

<div class="post-metadata">

**Author:** ![DanielT](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DanielT](https://discuss.bluerobotics.com/u/DanielT)\
**Post date:** [March 30, 2021, 1:37pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/6 "2021-03-30T13:37:24Z")

</div>

This works. Thank you. 🙂 😃

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [March 31, 2021, 1:49pm UTC](https://discuss.bluerobotics.com/t/ping-1d-with-ping-python-cant-connect-to-ping-viewer/9355/7 "2021-03-31T13:49:34Z")

</div>


