-
Notifications
You must be signed in to change notification settings - Fork 33
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
socket.py accept() status() weird behavior, might be the decorator, or I might be seeing things. #92
Comments
Hi @schaefer01, Please will you post some example code? This will allow me to better understand your issue and see if I am able to help. Thanks! |
I'll send a copy of the now working version winzip sockets. the purpose of the code that I had to modify was, if the 2040's mqtt broker was the wrong IP address, the mqtt connect would time out, the 2040 would switch to listening on its own socket IP and On the 2040 I replaced "status()" with "Status()"
[wiznet5k_socket.py.zip] |
Hi Bob, thanks for getting back to me with the files. I'm mystified as to why
The Cheers, Martin |
hi, |
Hi Bob,
Perhaps you could try to run a simple example like this to confirm whether Sorry that I took so long to get back to you. Cheers, Martin |
thank you, must have been me.
On Feb 17, 2023, at 2:59 PM, Martin Stephens ***@***.******@***.***>> wrote:
Hi Bob,
I've tried the Wiznet5K example wiznet5k_simpleserver.py and it works as it should. This is the code, slightly modified to work on my RPI2040 with a Wiznet 5100s:
import board
import busio
import digitalio
import adafruit_requests as requests
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
print("Wiznet5k SimpleServer Test")
cs = digitalio.DigitalInOut(board.GP17)
spi_bus = busio.SPI(board.GP18, MOSI=board.GP19, MISO=board.GP16)
eth = WIZNET5K(spi_bus, cs, is_dhcp=False, debug=True)
# (ip_address, subnet_mask, gateway_address, dns_server)
eth.ifconfig = (eth.unpretty_ip("192.168.11.3"),
eth.unpretty_ip("255.255.255.0"),
eth.unpretty_ip("192.168.11.1"),
(8, 8, 8, 8),)
# Initialize a socket for our server
socket.set_interface(eth)
server = socket.socket() # Allocate socket for the server
server_ip = eth.pretty_ip(eth.ip_address) # IP address of server
server_port = 50007 # Port to listen on
server.bind((server_ip, server_port)) # Bind to IP and Port
server.listen() # Begin listening for incoming clients
while True:
print(f"Accepting connections on {server_ip}:{server_port}")
conn, addr = server.accept() # Wait for a connection from a client.
print(f"Connection accepted from {addr}, reading exactly 1024 bytes from client")
with conn:
data = conn.recv(1024)
if data: # Wait for receiving data
print(data)
conn.send(data) # Echo message back to client
print("Connection closed")
Perhaps you could try to run a simple example like this to confirm whether socket.accept() is working on your system?
Sorry that I took so long to get back to you.
Cheers,
Martin
—
Reply to this email directly, view it on GitHub<#92 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMS2KELJTZFC43Z6OS6BINDWX7KA7ANCNFSM6AAAAAAUNXWI4A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I'm trying again from my previous closed issue with better information and a more humble attitude
The function status() is a decorator, when used inside accept(), the parenthesis is not there.
the accept does not work for me (feather rp2040) because status does not update.
When I added parentheses to "status" (which was where I was working on when I confused myself and canceled my last "issue),python raises syntax issues, probably because a side-effect of how the decorator works. Continuing on, realizing that perhaps the decorator aspect was not doing what it should be doing.
I created a new function named Status() identical to status() but without the decorator symbol,
I called Status() inside of accept() instead of "status" and the accept() call started working.
Can someone verify that there is an issue with status and the decorator, and I'm not just seeing things?
thank you,
bob s.
The text was updated successfully, but these errors were encountered: