Ethernet Entity¶
API Documentation: [cpp] [python] [.NET] [LabVIEW]
The Ethernet Entity provides control over network configuration and monitoring for devices with Ethernet connectivity. This includes IP address management, network configuration modes, and interface settings.
Ethernet Enable/Disable (Get/Set)¶
ethernet . getEnabled <= (unsigned char) enabled
ethernet . setEnabled => (unsigned char) enabled
Provides control (Set) and monitoring (Get) over the Ethernet interface. When enabled, the Ethernet interface is active and can be used for network communication.
Network Configuration (Get/Set)¶
ethernet . getNetworkConfiguration <= (unsigned char) configuration
ethernet . setNetworkConfiguration => (unsigned char) configuration
Returns or sets the network configuration mode for the Ethernet interface. This controls whether the interface uses DHCP or static IP configuration.
Value |
Name |
Description |
|---|---|---|
0 |
None |
No network configuration |
1 |
Static |
Static IP configuration |
2 |
DHCP |
DHCP automatic configuration |
Static IPv4 Address (Get/Set)¶
ethernet . getStaticIPv4Address <= (unsigned char[]) address
ethernet . setStaticIPv4Address => (unsigned char[]) address
Returns or sets the static IPv4 address for the Ethernet interface as a 4-byte array. This is used when the network configuration is set to static mode. Each byte represents one octet of the IP address (e.g., [192, 168, 1, 100] for “192.168.1.100”).
Static IPv4 Netmask (Get/Set)¶
ethernet . getStaticIPv4Netmask <= (unsigned char[]) netmask
ethernet . setStaticIPv4Netmask => (unsigned char[]) netmask
Returns or sets the static IPv4 netmask for the Ethernet interface as a 4-byte array. This is used when the network configuration is set to static mode. Each byte represents one octet of the netmask (e.g., [255, 255, 255, 0] for “255.255.255.0”).
Static IPv4 Gateway (Get/Set)¶
ethernet . getStaticIPv4Gateway <= (unsigned char[]) gateway
ethernet . setStaticIPv4Gateway => (unsigned char[]) gateway
Returns or sets the static IPv4 gateway address for the Ethernet interface as a 4-byte array. This is used when the network configuration is set to static mode. Each byte represents one octet of the gateway address (e.g., [192, 168, 1, 1] for “192.168.1.1”).
IPv4 Address (Get)¶
ethernet . getIPv4Address <= (unsigned char[]) address
Returns the current IPv4 address of the Ethernet interface as a 4-byte array. This reflects the actual address being used, whether obtained via DHCP or set statically. Each byte represents one octet of the IP address.
IPv4 Netmask (Get)¶
ethernet . getIPv4Netmask <= (unsigned char[]) netmask
Returns the current IPv4 netmask of the Ethernet interface as a 4-byte array. This reflects the actual netmask being used, whether obtained via DHCP or set statically. Each byte represents one octet of the netmask.
IPv4 Gateway (Get)¶
ethernet . getIPv4Gateway <= (unsigned char[]) gateway
Returns the current IPv4 gateway address of the Ethernet interface as a 4-byte array. This reflects the actual gateway being used, whether obtained via DHCP or set statically. Each byte represents one octet of the gateway address.
Static IPv4 DNS Address (Get/Set)¶
ethernet . getStaticIPv4DNSAddress <= (unsigned char[]) dns
ethernet . setStaticIPv4DNSAddress => (unsigned char[]) dns
Returns or sets the static IPv4 DNS server address for the Ethernet interface as a 4-byte array. This is used when the network configuration is set to static mode. Each byte represents one octet of the DNS address.
IPv4 DNS Address (Get)¶
ethernet . getIPv4DNSAddress <= (unsigned char[]) dns
Returns the current IPv4 DNS server address of the Ethernet interface as a 4-byte array. This reflects the actual DNS server being used, whether obtained via DHCP or set statically. Each byte represents one octet of the DNS address.
Hostname (Get/Set)¶
ethernet . getHostname <= (unsigned char[]) hostname
ethernet . setHostname => (unsigned char[]) hostname
Returns or sets the hostname for the Ethernet interface. The hostname is used for network identification and can be up to 63 characters long.
MAC Address (Get)¶
ethernet . getMACAddress <= (unsigned char[]) mac
Returns the MAC address of the Ethernet interface. This is a unique hardware identifier for the network interface.
Interface Port (Get/Set)¶
ethernet . getInterfacePort (unsigned char) service <= (unsigned short) port
ethernet . setInterfacePort => (unsigned char) service, (unsigned short) port
Returns or sets the interface port for specific services on the Ethernet interface. The service parameter specifies which service to configure, and the port parameter sets the port number for that service.
Name |
Value |
Description |
|---|---|---|
RestServer_HTTP |
0 |
HTTP REST API server |
RestServer_HTTPS |
1 |
HTTPS REST API server |
BrainStem_TCP |
2 |
BrainStem TCP communication |
BrainStem_DiscoveryRequest |
3 |
BrainStem discovery request port |
BrainStem_DiscoveryReply |
4 |
BrainStem discovery reply port |
Examples¶
// Enable Ethernet interface
ethernet.setEnabled(1);
// Set static IP configuration
ethernet.setNetworkConfiguration(1); // Static mode
unsigned char ip[4] = {192, 168, 1, 100};
unsigned char netmask[4] = {255, 255, 255, 0};
unsigned char gateway[4] = {192, 168, 1, 1};
ethernet.setStaticIPv4Address(ip, 4);
ethernet.setStaticIPv4Netmask(netmask, 4);
ethernet.setStaticIPv4Gateway(gateway, 4);
// Get current IP address
unsigned char current_ip[4];
ethernet.getIPv4Address(current_ip, 4);
// Set hostname
ethernet.setHostname("brainstem-device");
# Enable Ethernet interface
stem.ethernet.setEnabled(1)
# Set static IP configuration
stem.ethernet.setNetworkConfiguration(1) # Static mode
ip = [192, 168, 1, 100]
netmask = [255, 255, 255, 0]
gateway = [192, 168, 1, 1]
stem.ethernet.setStaticIPv4Address(ip)
stem.ethernet.setStaticIPv4Netmask(netmask)
stem.ethernet.setStaticIPv4Gateway(gateway)
# Get current IP address
current_ip = stem.ethernet.getIPv4Address()
print(current_ip.value)
# Set hostname
stem.ethernet.setHostname("brainstem-device")