Merge pull request #1460 from kwagyeman/kwabena/fix_network_usage_in_scripts

Kwabena/fix network usage in scripts
This commit is contained in:
Ibrahim Abd Elkader 2021-10-18 21:05:04 +02:00 committed by GitHub
commit d322bcf0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 292 additions and 158 deletions

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -7,7 +7,7 @@
import image, network, omv, rpc, sensor, struct, time
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or LAN/WLAN.
##############################################################
# Choose the interface you wish to control an OpenMV Cam over.

View File

@ -12,7 +12,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.

View File

@ -14,7 +14,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or WiFi.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -64,21 +64,21 @@ interface = rpc.rpc_uart_slave(baudrate=115200)
#
# interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs
@ -127,7 +127,7 @@ def person_detection(data):
# data is unused
def qrcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_qrcodes()
if not codes: return bytes() # No detections.
@ -139,7 +139,7 @@ def qrcode_detection(data):
# data is unused
def all_qrcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_qrcodes()
if not codes: return bytes() # No detections.
@ -177,7 +177,7 @@ def all_apriltag_detection(data):
# data is unused
def datamatrix_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_datamatrices()
if not codes: return bytes() # No detections.
@ -189,7 +189,7 @@ def datamatrix_detection(data):
# data is unused
def all_datamatrix_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_datamatrices()
if not codes: return bytes() # No detections.
@ -202,7 +202,7 @@ def all_datamatrix_detection(data):
# data is unused
def barcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((sensor.width(), sensor.height()//8))
codes = sensor.snapshot().find_barcodes()
if not codes: return bytes() # No detections.
@ -213,7 +213,7 @@ def barcode_detection(data):
# data is unused
def all_barcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((sensor.width(), sensor.height()//8))
codes = sensor.snapshot().find_barcodes()
if not codes: return bytes() # No detections.
@ -244,7 +244,7 @@ def color_detection(data):
#
# data is unused
def jpeg_snapshot(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
return sensor.snapshot().compress(quality=90).bytearray()

View File

@ -0,0 +1,79 @@
# RTSP Video Server
#
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
import network, omv, rtsp, sensor, time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
# Turn off the frame buffer connection to the IDE from the OpenMV Cam side.
#
# This needs to be done when manually compressing jpeg images at higher quality
# so that the OpenMV Cam does not try to stream them to the IDE using a fall back
# mechanism if the JPEG image is too large to fit in the IDE JPEG frame buffer on the OpenMV Cam.
omv.disable_fb(True)
# Setup Network Interface
network_if = network.LAN()
network_if.active(True)
network_if.ifconfig('dhcp')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#
# `pathname` is the name of the stream resource the client wants. You can ignore this if it's not
# needed. Otherwise, you can use it to determine what image object to return. By default the path
# name will be "/".
#
# `session` is random number that will change when a new connection is established. You can use
# session with a dictionary to differentiate different accesses to the same file name.
def setup_callback(pathname, session):
print("Opening \"%s\" in session %d" % (pathname, session))
def play_callback(pathname, session):
print("Playing \"%s\" in session %d" % (pathname, session))
def pause_callback(pathname, session): # VLC only pauses locally. This is never called.
print("Pausing \"%s\" in session %d" % (pathname, session))
def teardown_callback(pathname, session):
print("Closing \"%s\" in session %d" % (pathname, session))
server.register_setup_cb(setup_callback)
server.register_play_cb(play_callback)
server.register_pause_cb(pause_callback)
server.register_teardown_cb(teardown_callback)
# Track the current FPS.
clock = time.clock()
# Called each time a new frame is needed.
def image_callback(pathname, session):
clock.tick()
img = sensor.snapshot()
# Markup image and/or do various things.
print(clock.fps())
return img
# Stream does not return. It will call `image_callback` when it needs to get an image object to send
# to the remote rtsp client connecting to the server.
server.stream(image_callback)

View File

@ -0,0 +1,79 @@
# RTSP Video Server
#
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
import network, omv, rtsp, sensor, time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
# Turn off the frame buffer connection to the IDE from the OpenMV Cam side.
#
# This needs to be done when manually compressing jpeg images at higher quality
# so that the OpenMV Cam does not try to stream them to the IDE using a fall back
# mechanism if the JPEG image is too large to fit in the IDE JPEG frame buffer on the OpenMV Cam.
omv.disable_fb(True)
# Setup Network Interface
network_if = network.WLAN(network.STA_IF)
network_if.active(True)
network_if.connect('your-ssid', 'your-password')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#
# `pathname` is the name of the stream resource the client wants. You can ignore this if it's not
# needed. Otherwise, you can use it to determine what image object to return. By default the path
# name will be "/".
#
# `session` is random number that will change when a new connection is established. You can use
# session with a dictionary to differentiate different accesses to the same file name.
def setup_callback(pathname, session):
print("Opening \"%s\" in session %d" % (pathname, session))
def play_callback(pathname, session):
print("Playing \"%s\" in session %d" % (pathname, session))
def pause_callback(pathname, session): # VLC only pauses locally. This is never called.
print("Pausing \"%s\" in session %d" % (pathname, session))
def teardown_callback(pathname, session):
print("Closing \"%s\" in session %d" % (pathname, session))
server.register_setup_cb(setup_callback)
server.register_play_cb(play_callback)
server.register_pause_cb(pause_callback)
server.register_teardown_cb(teardown_callback)
# Track the current FPS.
clock = time.clock()
# Called each time a new frame is needed.
def image_callback(pathname, session):
clock.tick()
img = sensor.snapshot()
# Markup image and/or do various things.
print(clock.fps())
return img
# Stream does not return. It will call `image_callback` when it needs to get an image object to send
# to the remote rtsp client connecting to the server.
server.stream(image_callback)

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -7,7 +7,7 @@
import image, network, omv, rpc, sensor, struct, time
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or LAN/WLAN.
##############################################################
# Choose the interface you wish to control an OpenMV Cam over.

View File

@ -12,7 +12,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.

View File

@ -14,7 +14,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or WiFi.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -64,21 +64,21 @@ interface = rpc.rpc_uart_slave(baudrate=115200)
#
# interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -26,19 +26,15 @@ sensor.set_framesize(sensor.UXGA)
omv.disable_fb(True)
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to listen to (554).
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# Setup Network Interface
server = rtsp.rtsp_server(ssid="",
ssid_key="",
ssid_security=network.WINC.WPA_PSK,
port=554,
mode=network.WINC.MODE_STA,
static_ip=None)
network_if = network.LAN()
network_if.active(True)
network_if.ifconfig('dhcp')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#

View File

@ -11,6 +11,8 @@ import network, omv, rtsp, sensor, time
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.JPEG) # Only supported by the OV2640/OV5640.
@ -24,19 +26,15 @@ sensor.set_framesize(sensor.UXGA)
omv.disable_fb(True)
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to listen to (554).
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# Setup Network Interface
server = rtsp.rtsp_server(ssid="",
ssid_key="",
ssid_security=network.WINC.WPA_PSK,
port=554,
mode=network.WINC.MODE_STA,
static_ip=None)
network_if = network.WLAN(network.STA_IF)
network_if.active(True)
network_if.connect('your-ssid', 'your-password')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#

View File

@ -557,7 +557,7 @@ class rpc_usb_vcp_slave(rpc_slave):
def put_bytes(self, data, timeout_ms): # protected
self.__usb_vcp.send(data, timeout=timeout_ms)
class rpc_wifi_master(rpc_master):
class rpc_network_master(rpc_master):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:
@ -587,17 +587,11 @@ class rpc_wifi_master(rpc_master):
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, ip, port=0x1DBA, mode=network.WINC.MODE_STA, static_ip=None): # private
def __init__(self, network_if, port=0x1DBA): # private
self._udp_limit = 1400
self._timeout_scale = 10
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__slave_addr = (ip, port)
self.__tcp__socket = None
@ -708,7 +702,7 @@ class rpc_wifi_master(rpc_master):
except OSError: self.__close_tcp_socket()
if l: raise OSError # Stop Stream.
class rpc_wifi_slave(rpc_slave):
class rpc_network_slave(rpc_slave):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:
@ -734,17 +728,11 @@ class rpc_wifi_slave(rpc_slave):
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, port=0x1DBA, mode=network.WINC.MODE_STA, static_ip=None): # private
def __init__(self, network_if, port=0x1DBA): # private
self._udp_limit = 1400
self._timeout_scale = 10
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__master_addr = None
self.__tcp__socket = None

View File

@ -37,15 +37,9 @@ class rtsp_server:
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, port=554, mode=network.WINC.MODE_STA, static_ip=None): # private
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
def __init__(self, network_if, port=554): # private
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__tcp__socket = None
self.__udp__socket = None

View File

@ -712,7 +712,7 @@ extern const int kernel_high_pass_3[9];
#define IM_IS_GS(img) ((img)->pixfmt == PIXFORMAT_GRAYSCALE)
#define IM_IS_RGB565(img) ((img)->pixfmt == PIXFORMAT_RGB565)
#define IM_IS_BAYER(img) ((img)->is_bayer)
#define IM_IS_JPEG(img) ((img)->pixfmt == PIXFORMAT_ID_JPEG)
#define IM_IS_JPEG(img) ((img)->pixfmt == PIXFORMAT_JPEG)
#define IM_X_INSIDE(img, x) \
({ __typeof__ (img) _img = (img); \

View File

@ -173,7 +173,7 @@ Creates a master implementation of the `rpc` library to communicate over a hardw
Please use the `rpc_usb_vcp_master` to talk to the OpenMV Cam over its USB interface. This class is for talking to the OpenMV Cam over its hardware UART.
If you are using this class with USB to serial converters you will likely experience intermittent synchronization issues. The RPC library uart interface on the OpenMV Cam is designed to work with real-time UARTs like hardware RS232/RS422/RS485 COM ports on PCs and TTL UARTS on single board computers like the RaspberryPi and Beaglebone. That said, the interface library can handle this and will continue to work.
If you are using this class with USB to serial converters you will likely experience intermittent synchronization issues. The RPC library uart interface on the OpenMV Cam is designed to work with real-time UARTs like hardware RS232/RS422/RS485 COM ports on PCs and TTL UARTS on single board computers like the RaspberryPi and Beaglebone. That said, the interface library can handle this and will continue to work.
## rpc_uart_slave(port, baudrate=9600)
@ -181,7 +181,7 @@ Creates a slave implementation of the `rpc` library to communicate over a hardwa
Please use the `rpc_usb_vcp_slave` to talk to the OpenMV Cam over its USB interface. This class is for talking to the OpenMV Cam over its hardware UART.
If you are using this class with USB to serial converters you will likely experience intermittent synchronization issues. The RPC library uart interface on the OpenMV Cam is designed to work with real-time UARTs like hardware RS232/RS422/RS485 COM ports on PCs and TTL UARTS on single board computers like the RaspberryPi and Beaglebone. That said, the interface library can handle this and will continue to work.
If you are using this class with USB to serial converters you will likely experience intermittent synchronization issues. The RPC library uart interface on the OpenMV Cam is designed to work with real-time UARTs like hardware RS232/RS422/RS485 COM ports on PCs and TTL UARTS on single board computers like the RaspberryPi and Beaglebone. That said, the interface library can handle this and will continue to work.
## rpc_usb_vcp_master(port):
@ -195,11 +195,11 @@ Creates a slave implementation of the `rpc` library to communicate over a USB VC
Communication over USB is the most reliable and high speed way to connect an OpenMV Cam to a computer. However, as the OpenMV Cam has only one VCP port we recommend that you fully debug your script using the `rpc_usb_vcp_master` on your OpenMV using another `rpc` interface if possible as you will not be able to get error messages off the OpenMV Cam easily. For example, connecting the `rpc_usb_vcp_slave` to the `rpc_uart_master` on your OpenMV Cam at 115200 BPS over a USB-to-Serial adapter when debugging will make your life far easier. Alternatively, use the Ethernet or WiFi interface when debugging.
## rpc_wifi_or_ethernet_master(slave_ip, my_ip="", port=0x1DBA):
## rpc_network_master(slave_ip, my_ip="", port=0x1DBA):
Creates a master implementation of the `rpc` library to communicate over WiFi or Ethernet. `slave_ip` is the IPV4 address of the `rpc` slave device. `my_ip` can be `""` which binds the master to any interface adapter to communicate to the slave. If `my_ip` is not `""` then it should be an IP address on the same subnet as `slave_ip`. `port` is a free port to use for UDP and TCP traffic.
## rpc_wifi_or_ethernet_slave(my_ip="", port=0x1DBA):
## rpc_network_slave(my_ip="", port=0x1DBA):
Creates a slave implementation of the `rpc` library to communicate over WiFi or Ethernet. `my_ip` can be `""` which binds the slave to any interface adapter to communicate to the master. If `my_ip` is not `""` then it should be an IP address on the same subnet as the master. `port` is a free port to use for UDP and TCP traffic.

View File

@ -437,7 +437,7 @@ class rpc_usb_vcp_slave(rpc_slave):
if int(self.__ser.timeout) != 1: self.__ser.timeout = 1 # Changing this causes control transfers.
return self.__get_bytes(buff)
class rpc_wifi_or_ethernet_master(rpc_master):
class rpc_network_master(rpc_master):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:
@ -584,7 +584,7 @@ class rpc_wifi_or_ethernet_master(rpc_master):
except (socket.timeout, socket.error): self.__close_tcp_socket()
if l: raise OSError # Stop Stream.
class rpc_wifi_or_ethernet_slave(rpc_slave):
class rpc_network_slave(rpc_slave):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:

View File

@ -36,7 +36,7 @@ sys.stdout.flush()
# * my_ip - IP address to bind to ("" to bind to all interfaces...)
# * port - Port to route traffic to.
#
# interface = rpc.rpc_wifi_or_ethernet_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
# interface = rpc.rpc_network_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
##############################################################
# Call Back Handlers

View File

@ -36,7 +36,7 @@ sys.stdout.flush()
# * my_ip - IP address to bind to ("" to bind to all interfaces...)
# * port - Port to route traffic to.
#
# interface = rpc.rpc_wifi_or_ethernet_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
# interface = rpc.rpc_network_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
##############################################################
# Call Back Handlers

View File

@ -34,7 +34,7 @@ sys.stdout.flush()
# * my_ip - IP address to bind to ("" to bind to all interfaces...)
# * port - Port to route traffic to.
#
# interface = rpc.rpc_wifi_or_ethernet_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
# interface = rpc.rpc_network_master(slave_ip="xxx.xxx.xxx.xxx", my_ip="", port=0x1DBA)
# Uncomment the below lines to setup your OpenMV Cam for controlling over a UART (Serial / COM Port).
#