RS232 Serial Communication¶
The RS232 Serial Communication feature allows one to send commands to control and configure USB-C-Switch Pro.
Use Cases
Affecting USB-C-Switch Pro control.Audio/Video applications.
Configuration¶
The default configuration of the RS232 Serial Communication feature is:
8 Data bitsNo ParityNo Flow Control1 Stop bit9600 Baudrate
This feature does have some configurability through the USB-C-Switch Pro UART Entity
Extron Compatible Serial Commands¶
Using a protocol compatible with Extron’s Simple Instruction Set over RS232, the RS232 Serial Communication feature can:
Select / Enable / Disable Mux ports
Query the USB-C-Switch Pro part number and firmware version.
Commands¶
The following is a list of all commands the USB-C-Switch Pro supports with their arguments, descriptions, and expected responses. For USB-C-Switch Pro, “Upstream Port” refers to the Mux port index independent of the port direction.
Cmd |
Arguments |
Description |
Expected Responses |
|---|---|---|---|
|
None |
Get current mux port index |
|
|
|
Change mux port to |
|
|
|
Change mux port to |
|
|
None |
Get part number |
S105-USB-C-SWITCH-PRO\r\n |
|
None |
Get firmware version |
|
|
|
Get enable/disable status of |
Port #*0\r\nPort #*1\r\n |
|
# Port$ Enable 0/1 |
Set |
|
Error Codes¶
The following is a list of all error codes the USB-C-Switch Pro supports with descriptions.
Code |
Description |
|---|---|
|
invalid port number, check the port number and make sure it’s valid. |
|
invalid command, verify that you formatted the command correctly. |
|
invalid value, verify that the value is within the acceptable range for this command. |
|
invalid configuration, verify the system is in a state it can accept this command. |
General Notes¶
All commands are ASCII strings.\ris the ASCII character for carriage return.\nis the ASCII character for new line.
Examples¶
Extron Compatible Serial Commands:
1!Chn 1\r\n3*0PPort 3*0\r\nAPI Configurations:
static const int TEST_SERIAL = 0;
aUSBCSwitchPro stem;
stem.discoverAndConnect(USB);
// Enable the port
stem.uart[TEST_SERIAL].setEnable(true);
// Change baudrate to 115200 from default 9600
stem.uart[TEST_SERIAL].setBaudRate(115200);
// Change Protocol to Extron Compatible
// 0 - Disabled/Undefined
// 1 - Extron Compatible
// 2 - Brainstem Transport
// 6 - Loopback
stem.uart[TEST_SERIAL].setProtocol(1)
// Perform a system save so the changes persist
// through power cycles
stem.system.save();
stem.disconnect();
TEST_SERIAL = 0
stem = brainstem.stem.USBCSwitchPro()
stem.discoverAndConnect(brainstem.link.Spec.USB)
# Enable the port
stem.uart[TEST_SERIAL].setEnable(1)
# Change baudrate to 115200 from default 9600
stem.uart[TEST_SERIAL].setBaudRate(115200)
# Change Protocol to Extron Compatible
# 0 - Disabled/Undefined
# 1 - Extron Compatible
# 2 - Brainstem Transport
# 6 - Loopback
stem.uart[TEST_SERIAL].setProtocol(1)
# Perform a system save so the changes persist
# through power cycles
stem.system.save()
stem.disconnect()
# Configure UART[0] for loopback testing
# Data sent to the UART will be echoed back
TEST_SERIAL = 0
stem = brainstem.stem.USBCSwitchPro()
stem.discoverAndConnect(brainstem.link.Spec.USB)
stem.uart[TEST_SERIAL].setEnable(1)
stem.uart[TEST_SERIAL].setBaudRate(115200)
stem.uart[TEST_SERIAL].setProtocol(6) # Loopback protocol
# Now any data sent to UART[0] will be echoed back
stem.system.save()
stem.disconnect()
# Link VCOM channel (UART[1]) to hardware RS232 (UART[0])
# This allows USB serial communication to be forwarded to RS232
stem = brainstem.stem.USBCSwitchPro()
stem.discoverAndConnect(brainstem.link.Spec.USB)
# Enable both channels
stem.uart[0].setEnable(1) # Hardware RS232
stem.uart[1].setEnable(1) # VCOM channel
# Configure matching baud rates
stem.uart[0].setBaudRate(115200)
stem.uart[1].setBaudRate(115200)
# Link VCOM to hardware UART
stem.uart[0].setLinkChannel(1)
stem.uart[1].setLinkChannel(0)
# Data received on VCOM will now be forwarded to RS232,
# and data received on RS232 will be forwarded to VCOM
stem.system.save()
stem.disconnect()
// Configure UART[0] for loopback testing
// Data sent to the UART will be echoed back
static const int TEST_SERIAL = 0;
aUSBCSwitchPro stem;
stem.discoverAndConnect(USB);
stem.uart[TEST_SERIAL].setEnable(true);
stem.uart[TEST_SERIAL].setBaudRate(115200);
stem.uart[TEST_SERIAL].setProtocol(6); // Loopback protocol
// Now any data sent to UART[0] will be echoed back
stem.system.save();
stem.disconnect();
// Link VCOM channel (UART[1]) to hardware RS232 (UART[0])
// This allows USB serial communication to be forwarded to RS232
aUSBCSwitchPro stem;
stem.discoverAndConnect(USB);
// Enable both channels
stem.uart[0].setEnable(true); // Hardware RS232
stem.uart[1].setEnable(true); // VCOM channel
// Configure matching baud rates
stem.uart[0].setBaudRate(115200);
stem.uart[1].setBaudRate(115200);
// Link VCOM to hardware UART
stem.uart[0].setLinkChannel(1);
stem.uart[1].setLinkChannel(0);
// Data received on VCOM will now be forwarded to RS232,
// and data received on RS232 will be forwarded to VCOM
stem.system.save();
stem.disconnect()