Siemens Logo! 8 <-> pymodbus - python-3.x

Using Siemens Logo!Soft Comfort, I want to connect a Siemens Logo! (8) with pymodbus
Settings on a network input on siemens soft comfort (I also tried Unit ID 255 and Modbus Type "DI" (Digital input))
Pc Settings, (I have tried both Interfaces)
Pymodbus code:
import time
client = ModbusTcpClient('192.168.0.3')
print(client.connect())
while True:
time.sleep(1)
print(client.write_coil(1, True))
time.sleep(1)
print(client.write_coil(1, False))
The output:
True
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host

There are two ways to connect to the Logo via PC, either with the Logo acting as a Modbus server or a Modbus client.
LOGO! as a Modbus server:
Add a server connection:
Leave the options completely empty:
You should then see a little yellow socket at the bottom of the logo:
No further configuration is needed (the Diagram Editor can be left empty)
Push this configuration to the Logo:
Send modbus-tcp-messages to the Logo, as described in the original post. The coils to target are described in the Logo!-Settings (they start at 1, while pymodbus starts at 0, so you need to subtract 1:
So if we want to turn on the Q1:
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('192.168.0.3') # Default port is 502
client.write_coil(address=8192, value=True) # Default unit_id is 1
LOGO! as Client
Add a Client connection:
Enter the values you want to read:
Run a modbus server, see Documentation

Related

Pyads connection refused with Beckhoff running Twincat 3

I am trying to make a connection from a server running Ubuntu to a Beckhoff PLC with TwinCAT 3. With Windows everything works fine but with the same server on Linux I can't get a connection.
The Linux server has a static IP and in the route manager in the PLC I can find the route and see the server. I have tried adding the route by the route manager in the PLC and with "add_route_to_plc" but both ways my connection is refused. I have already turned off all firewalls. Any of you guys any idea what goes wrong here? In the attachment I have added some picture to see my settings and code that I try to run.
Python error: "connection closed by remote"
Python code:
import pyads
SENDER_AMS = '192.168.1.180.1.1'
PLC_IP = '192.168.1.100'
PLC_USERNAME = 'Administrator'
PLC_PASSWORD = '1'
ROUTE_NAME = 'GID_TEST_ROUTE'
HOSTNAME = 'Grid-stabilizer'
pyads.open_port()
pyads.set_local_address(SENDER_AMS)
pyads.add_route_to_plc(SENDER_AMS, HOSTNAME, PLC_IP, PLC_USERNAME, PLC_PASSWORD, route_name=ROUTE_NAME)
pyads.close_port()
plc=pyads.Connection('192.168.1.100.1.1', pyads.PORT_TC3PLC1)
plc.open()
plc.read_state()
If you are running python on linux and the plc on windows try
plc=pyads.Connection('192.168.1.100.1.1', pyads.PORT_TC3PLC1, PLC_IP)
This will create a route on the linux system. In your code the ip is missing to create a proper route.
Check the port of your plc. It should be 851.

How to find the first host contacted by cassandra driver during connection?

Is there a way to find out which node was contacted first during the initial setup by the driver? For example, is there a way to find the host 10.9.58.64 that was contacted?
WARNING:cassandra.cluster:Cluster.__init__ called with contact_points specified, but no load_balancing_policy. In the next major version, this will raise an error; please specify a load-balancing policy. (contact_points = ['cassandranode1,;cassandranode2'], lbp = None)
DEBUG:cassandra.cluster:Connecting to cluster, contact points: ['cassandranode1,;cassandranode2']; protocol version: 4
DEBUG:cassandra.io.asyncorereactor:Validated loop dispatch with cassandra.io.asyncorereactor._AsyncorePipeDispatcher
DEBUG:cassandra.pool:Host 10.9.58.64 is now marked up
DEBUG:cassandra.pool:Host 10.9.58.65 is now marked up
DEBUG:cassandra.cluster:[control connection] Opening new connection to 10.9.58.64
Right after the connection is established you can use the cluster.get_control_connection_host function to get information about host to which so-called control connection is established. It's used for administrative purposes, such as getting the updates on the status of the nodes in the cluster, etc. There is more information about control connection in the documentation of Java driver.

Azure Point to Site VPN with Basic SKU not working on Windows 10 (ErrorCode = 720 ErrorSource = RAS)

I am trying to connect to Azure vNET Gateway and I am not having success. It ends with ErrorCode = 720 ErrorSource = RAS. Anyone experienced this issue before for the following scenario?
Azure vNET Gateway configured with Basic SKU.
VpnStrategy is SSTP for Windows 10
Authentication: Client certificate (self signed)
Both the root and client certificates are in current user personal store. They are resolved ok.
Root cert is stored in trusted root path of current user
Root cert is saved in Azure vpn gateway user configuration without line breaks
Don't wish to create other SKU to save $$ on poc
Deleted all the WAN Miniport adapters and rebooted the machine with no success. They get recreated automatically
I can't share certificates (root or client) in this forum since I am revealing the vpn gateway endpoint in the logs (for security reason)
Event logs from local machine in the order of execution:
CoId={3285D778-432A-4746-B74C-8B95FECEB53E}: The user SYSTEM has started dialing a Connection Manager connection using a per-user connection profile named az-aks-vnet-v2. The connection settings are:
Dial-in User = P2SDemoClientCert
VpnStrategy = SSTP
DataEncryption = Require
PrerequisiteEntry =
AutoLogon = No
UseRasCredentials = Yes
Authentication Type = EAP <Microsoft: Smart Card or other certificate>
Ipv4DefaultGateway = No
Ipv4AddressAssignment = By Server
Ipv4DNSServerAssignment = By Server
Ipv6DefaultGateway = Yes
Ipv6AddressAssignment = By Server
Ipv6DNSServerAssignment = By Server
IpDnsFlags =
IpNBTEnabled = Yes
UseFlags = Private Connection
ConnectOnWinlogon = No.
CoId={3285D778-432A-4746-B74C-8B95FECEB53E}: The user SYSTEM is trying to establish a link to the Remote Access Server for the connection named az-aks-vnet-v2 using the following device:
Server address/Phone Number = azuregateway-b80c0077-e69d-4f0c-8f50-baa0c7a6e23e-0fe0aceeddbb.vpn.azure.com
Device = WAN Miniport (SSTP)
Port = VPN1-1
MediaType = VPN.
CoId={3285D778-432A-4746-B74C-8B95FECEB53E}: The user SYSTEM has successfully established a link to the Remote Access Server using the following device:
Server address/Phone Number = azuregateway-b80c0077-e69d-4f0c-8f50-baa0c7a6e23e-0fe0aceeddbb.vpn.azure.com
Device = WAN Miniport (SSTP)
Port = VPN1-1
MediaType = VPN.
CoId={3285D778-432A-4746-B74C-8B95FECEB53E}: The link to the Remote Access Server has been established by user SYSTEM.
CoId={3285D778-432A-4746-B74C-8B95FECEB53E}: The user SYSTEM dialed a connection named az-aks-vnet-v2 which has failed. The error code returned on failure is 720.
VPN logs:
******************************************************************
Operating System : Windows NT 10.0
Dialer Version : 7.2.18362.1
Connection Name : az-aks-vnet-v2
All Users/Single User : Single User
Start Date/Time : 6/22/2020, 10:31:31
******************************************************************
Module Name, Time, Log ID, Log Item Name, Other Info
For Connection Type, 0=dial-up, 1=VPN, 2=VPN over dial-up
******************************************************************
[cmdial32] 10:31:31 03 Pre-Init Event CallingProcess = C:\WINDOWS\system32\rasautou.exe
[cmdial32] 10:31:40 04 Pre-Connect Event ConnectionType = 1
[cmdial32] 10:31:40 06 Pre-Tunnel Event UserName = P2SDemoClientCert Domain = DUNSetting = b80c0077-e69d-4f0c-8f50-baa0c7a6e23e Tunnel DeviceName = TunnelAddress = azuregateway-b80c0077-e69d-4f0c-8f50-baa0c7a6e23e-0fe0aceeddbb.vpn.azure.com
[cmdial32] 10:31:42 21 On-Error Event ErrorCode = 720 ErrorSource = RAS
Thanks in advance for the help.
The problem is resolved, I just needed a break from computer and take a long evening walk! This is what I did to fix the problem-
Open Device Manager
Go to Network Adapters
Uninstall all the adapters name starts with "WAN Miniport". Repeat the step for every “WAN Miniport driver” installed
I didn't reboot the machine.
Right click “Network adapters” and select “Scan for hardware changes”
All of the WAN Miniport adapters will reappear immediately
I was able to connect to the VPN Gateway after the above steps and connect to VM with private ip.
Thanks to svenvdveen for the solution with the exception of no reboot. I followed the same instruction (twice) before and I rebooted the machine but didn't have luck!
I ran into a similar issue with Azure Basic Gateway.
For anyone reading this, I suggest you start by simply uninstalling the Wan Miniport (Ikev2). Then try to connect to your VPN again. It worked in my case :).
(Windows 11)

Screen Sharing using OPensips ,Blink and Sylk server

I want to implement screen sharing using opensips , Blink and Sylk server utilities.
When I use msrp relay and opensips setup i get following errors:
debug: session
y2tmlOfHnQHa3mBUxG50IzE0NTMyODY3OTcuNTQzOjE5Mi4xNjguNy4xNzU= for
1009#192.168.5.178 (UNBOUND): AUTH succeeded, creating new session
debug: session
y2tmlOfHnQHa3mBUxG50IzE0NTMyODY3OTcuNTQzOjE5Mi4xNjguNy4xNzU= for
1009#192.168.5.178 (UNBOUND): Connection lost: Connection was closed
cleanly.
debug: session
y2tmlOfHnQHa3mBUxG50IzE0NTMyODY3OTcuNTQzOjE5Mi4xNjguNy4xNzU= for
1009#192.168.5.178 (DISCONNECTED): bytes sent: 408, bytes received: 0
I suspect if we can use msrp relay for screen sharing as i just found IM and File share as the features in its documentation.
Can somebody help me with this implementation?
Can we use sylk server in the server setting option of blink client instead of msrprelay with 5061 port?

WinCE: 10053 error during connect

I wrote a Bluetooth client program for a wince 4.2 device. The device discovery works fine. However, when I attempt to connect to a PC, the connect function immediately returns with error code 10053. The connection request was being processed by the PC with a prompt to enter the authentication code but the wince device doesn’t seem to wait.
What could be causing this issue? I am using the following steps (removed error handling for simplicity):
WSAStartup(..)…////was successful.
SOCKET m_Socket =Socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); //was successful.
SOCKADDR_BTH sClinet;
memset (&sClinet, 0, sizeof(sClinet));
sClinet.addressFamily = AF_BTH;
sClinet.btAddr = btd.btaddr; ; //BT_ADDR of the PC obtained via Device Discovery..
sClinet.port = BT_PORT_ANY; //I did try 0, did not help!
sClinet.serviceClassId = RFCOMM_PROTOCOL_UUID;
int nConErr = connect (m_Socket, (SOCKADDR *)&sClinet, sizeof(sClinet));
nConErr returns 10053 immediately. It doesn’t even wait, even though the PC recognized the connection and prompted a message to enter the PIN for authentication.
From what you are describing it looks like it is a pairing/authentication problem. You should consider in using also setsockopt function: http://msdn.microsoft.com/en-us/library/ms863347.aspx
You should try to use SO_BTH_AUTHENTICATE option which according to MSDN:
On connected socket, triggers authentication. On not connected socket, forces authentication on connection. For incoming connection this means that connection is rejected if authentication cannot be performed.
So before calling connect function you should set options to your socket.

Resources