can't ping through ethernet
-
i was trying to ping from the omega to my pc, and to an another device (a servo-drive), actually now it pings, but still it can't connect to the servo drive through ethernet.
ps : i'm using the pymodbus library in order to connect to this device it worked with my pc but not with the omega here's the code
from pymodbus.client.sync import ModbusTcpClient
import timeclient = ModbusTcpClient('192.168.0.3',502)
conected = client.connect()
print(conected)
time.sleep(1)
#OVERRIDE
client.write_register(4,16384)
client.write_register(9,16384)
client.write_register(10,16384)
#enable power stage
client.write_register(0,1030)
#time.sleep(0.01)
client.write_register(0,1031)
#time.sleep(0.01)
client.write_register(0,1039)
#time.sleep(0.01)
print("Power stage enabled")
#disable power stage
time.sleep(2)
client.write_register(0,0)
time.sleep(1)
client.close()
-
@Ghofran-Daoues OK so first you need to check if the Omega2 can get to the port. An easy solution is to run the nmap command I gave you in the previous thread. nmap -p 502 192.168.0.3
BTW if you don't want to fix your firewall rules, and just keep the firewall down, you can use the command service firewall disable so the firewall will not come back up when you reboot.
-
the other time i tried to run the nmap command but coudn't it find it (nmap) and i couldn't install
command not found/ unknown package
-
@Ghofran-Daoues you can use the nc command instead. nc 192.168.0.3 502
If the port is closed or inaccessible then you'll get a connected refused error, if the port is accessible you'll just get a flashing cursor, press enter and you should get something back from port.
If you cannot connect then post the output of the route command.
-
apparently this is my problem !
-
The output of route command !
-
@Ghofran-Daoues ok so earlier you said you can ping the device (192.168.0.3) after stopping your firewall. The error you have here indicates your Omega2 can't even ping device. So my guess is the firewall has restarted. So let's get back to the basics again. Stop and disable your firewall:
service firewall stop
service firewall disable
rebootping 192.168.0.3
nc 192.168.0.3 502
route
ifconfigPlease post the output of all of these commands.
Is your Omega2 ethernet connected directly to your device or is it connected via a switch/router?
-
yes that's true it doesn't ping anymore
here are my outputs :
service firewall stop
ping 192.168.0.3
nc 192.168.0.3 502
route
ifconfig
-
@Ghofran-Daoues Look at the output of ifconfig, you can see your ethernet has no IPv4 address. Check your cable. You missed my last question: "Is your Omega2 ethernet connected directly to your device or is it connected via a switch/router?"
If your Omega2 is connecting directly to the device using an ethernet cable then you need to set a static IP on the Omega2 ethernet unless your device runs a dhcpd, which is unlikely. So I need to understand how you are connected via ethernet.
-
omega2+ is directly connected using ethernet cable and the device doesn't run a dhcp, how to set a static ip on the omega ?
-
@Ghofran-Daoues this is controlled in the network config file (/etc/config/network), look for the entry for eth0, something like this:
config interface 'wan'
option ifname 'eth0'
option proto 'dhcp'Change it to:
config interface 'wan'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.0.10'
option netmask '255.255.255.0'Then run service network restart and try pinging etc again
-
even after setting an ip to the ethernet and disabling the firewall, it doesn't ping .
the output of ifconfig and ping 192.168.0.3 :
-
@Ghofran-Daoues That looks correct, check your cable and restart the device in case it has stopped listening.
-
At this moment, i think my problem is hardware-related, actually i broke my expansion dock and i did some tricks to use it again, i thaught it worked but since then he's not seeing the ethernet dock, and when i power the expansion dock the led is green (usually it's red)
-
@Ghofran-Daoues Your config looks correct now which is why I suggested checking cable and device. You might try plugging the ethernet cable into you computer, set a static IP in the same subnet
then try to ping the Omega2 from the computer, if that fails then it's probably hardware.