mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1007 from openmv/portenta_ethernet
PORTENTA: Enable Ethernet.
This commit is contained in:
commit
b3bef0820a
30
scripts/examples/Arduino/38-Ethernet/http_client.py
Normal file
30
scripts/examples/Arduino/38-Ethernet/http_client.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Ethernet LAN HTTP client example.
|
||||
import network, usocket
|
||||
|
||||
PORT = 80
|
||||
HOST = "www.google.com"
|
||||
|
||||
lan = network.LAN()
|
||||
lan.active(True)
|
||||
lan.ifconfig('dhcp')
|
||||
|
||||
# We should have a valid IP now via DHCP
|
||||
print(lan.ifconfig())
|
||||
|
||||
# Get addr info via DNS
|
||||
addr = usocket.getaddrinfo(HOST, PORT)[0][4]
|
||||
print(addr)
|
||||
|
||||
# Create a new socket and connect to addr
|
||||
client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
|
||||
client.connect(addr)
|
||||
|
||||
# Set timeout
|
||||
client.settimeout(3.0)
|
||||
|
||||
# Send HTTP request and recv response
|
||||
client.send("GET / HTTP/1.1\r\nHost: %s\r\n\r\n"%(HOST))
|
||||
print(client.recv(1024))
|
||||
|
||||
# Close socket
|
||||
client.close()
|
||||
39
scripts/examples/Arduino/38-Ethernet/http_client_ssl.py
Normal file
39
scripts/examples/Arduino/38-Ethernet/http_client_ssl.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Ethernet LAN HTTP client example.
|
||||
import network, usocket, ussl
|
||||
|
||||
PORT = 443
|
||||
HOST = "www.google.com"
|
||||
|
||||
lan = network.LAN()
|
||||
lan.active(True)
|
||||
lan.ifconfig('dhcp')
|
||||
|
||||
# We should have a valid IP now via DHCP
|
||||
print(lan.ifconfig())
|
||||
|
||||
# Get addr info via DNS
|
||||
addr = usocket.getaddrinfo(HOST, PORT)[0][4]
|
||||
print(addr)
|
||||
|
||||
# Create a new socket and connect to addr
|
||||
client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
|
||||
client.connect(addr)
|
||||
|
||||
# Set timeout
|
||||
client.settimeout(3.0)
|
||||
client = ussl.wrap_socket(client, server_hostname=HOST)
|
||||
|
||||
# Send HTTP request and recv response
|
||||
request = "GET / HTTP/1.1\r\n"
|
||||
request += "HOST: %s\r\n"
|
||||
request += "User-Agent: Mozilla/5.0\r\n"
|
||||
request += "Connection: keep-alive\r\n\r\n"
|
||||
# Add more headers if needed.
|
||||
client.write(request%(HOST)+"\r\n")
|
||||
|
||||
response = client.read(1024)
|
||||
for l in response.split(b"\r\n"):
|
||||
print(l.decode())
|
||||
|
||||
# Close socket
|
||||
client.close()
|
||||
15
scripts/examples/Arduino/38-Ethernet/peer_to_peer.py
Normal file
15
scripts/examples/Arduino/38-Ethernet/peer_to_peer.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Ethernet LAN Peer to Peer example.
|
||||
# On the PC try the following:
|
||||
#
|
||||
# $> sudo ifconfig eth0 192.168.1.102 up
|
||||
# $> ping 192.168.1.102
|
||||
|
||||
import network, time
|
||||
|
||||
lan = network.LAN()
|
||||
lan.active(True)
|
||||
lan.ifconfig(('192.168.1.100', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
|
||||
|
||||
while (True):
|
||||
# Nothing else to do.
|
||||
time.sleep(1.0)
|
||||
@ -347,6 +347,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(MICROPY_DIR)/,\
|
||||
pendsv.o \
|
||||
bufhelper.o \
|
||||
usb.o \
|
||||
eth.o \
|
||||
gccollect.o \
|
||||
help.o \
|
||||
flash.o \
|
||||
@ -388,6 +389,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(MICROPY_DIR)/,\
|
||||
moduos.o \
|
||||
modutime.o \
|
||||
modusocket.o \
|
||||
network_lan.o \
|
||||
modnetwork.o \
|
||||
modmachine.o \
|
||||
machine_i2c.o \
|
||||
@ -400,7 +402,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(MICROPY_DIR)/,\
|
||||
posix_helpers.o \
|
||||
softtimer.o \
|
||||
mbedtls/mbedtls_port.o \
|
||||
frozen_content.o \
|
||||
frozen_content.o \
|
||||
)
|
||||
|
||||
# board object files
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 07aaa0cc42dd11e1eba7e749d4e4f9063deb444f
|
||||
Subproject commit 64655f1492b42a650bb01077fea7b6ee757764e5
|
||||
@ -145,7 +145,7 @@
|
||||
#define OMV_FB_SIZE (4M) // FB memory: header + VGA/GS image
|
||||
#define OMV_FB_ALLOC_SIZE (3M) // minimum fb alloc size
|
||||
#define OMV_STACK_SIZE (32K)
|
||||
#define OMV_HEAP_SIZE (210K)
|
||||
#define OMV_HEAP_SIZE (182K)
|
||||
#define OMV_SDRAM_SIZE (8 * 1024 * 1024) // This needs to be here for UVC firmware.
|
||||
|
||||
#define OMV_LINE_BUF_SIZE (11 * 1024) // Image line buffer round(2592 * 2BPP * 2 buffers).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user