CAN, RS232 and RS485
The AT1000 features multiple industrial communication interfaces, including:
- 1 CAN bus
- 2 RS485 buses
- 1 RS232 buses
As decribed in the introduction industrial communication interfaces share GPIOs, meaning only one feature can be enabled at a given time: Either regular GPIOs, or one of the industrial communication interfaces.
CAN and RS485 0​
The CAN bus and RS485_0 share the same GPIO pins for communication. Therefore, only one of these interfaces can be enabled at a time.
When enabling either the CAN bus or RS485_0, the shared GPIO pins will be automatically configured for the selected interface.
In order to avoid any confusion, we recommend following this standard procedure when using an industrial communication port:
- Start by enabling the port
- Disable to port when done using it.
If there are any conflicts (e.g. enabling an interface before disabling another one that uses the same resources), an error will be raised during the configure() phase, allowing you to easily detect and correct any conflicts.
CAN Bus API​
The CAN bus supports enabling/disabling, termination resistance, setting message acceptance filters, transmitting, and receiving data.
- NodeJS
- Python
import AT1000 from '@ikalogic/at1000';
let testers = await AT1000.findDevices(500); // Find the device with serial number 12345
let tester = testers[0]; // Target the first detected device
let can = tester.com.can(0); // Access CAN bus 0 on AT1000
// Enable CAN bus on AT1000
let can_cfg_result = await can.configure(
{
baud_rate:500000,
enabled : true,
termination_resistors:true,
rx_filters:[{
mask:0xFF9F,
filter:0x25A,
extended_id: false
}]
});
// Start receiving CAN messages
await can.start_rx(); // Updated to use the 'can' variable
// Transmit a CAN message
await can.tx({can_id:0x123, data:[0x11, 0x22, 0x33, 0x44]});
//add delay of 100ms
await new Promise(resolve => setTimeout(resolve, 100));
// Receive messages (returns an array of objects containing ID & data)
let data_rx = await can.rx();
// Print received messages
data_rx.forEach(msg => {
console.log(`CAN Message ID: ${msg.id}, Data: ${msg.data}`);
});
// Disable CAN bus receiving
await can.stop_rx();
from ikalogic_at1000 import AT1000
import asyncio
testers = await AT1000.find_devices(500) # Find the device with serial number 12345
tester = testers[0] # Target the first detected device
can = tester.com.can(0) # Access CAN bus 0 on AT1000
# Enable CAN bus on AT1000
can_cfg_result = await can.configure(
{
'baud_rate':500000,
'enabled' : True,
'termination_resistors':True,
'rx_filters':[{
'mask':0xFF9F,
'filter':0x25A,
'extended_id': False
}]
})
# Start receiving CAN messages
await can.start_rx() # Updated to use the 'can' variable
# Transmit a CAN message
await can.tx({'can_id':0x123, 'data':[0x11, 0x22, 0x33, 0x44]})
# add delay of 100ms
await asyncio.sleep(0.1)
# Receive messages (returns an array of objects containing ID & data)
data_rx = await can.rx()
# Print received messages
for msg in data_rx:
print(f"CAN Message ID: {msg['id']}, Data: {msg['data']}")
# Disable CAN bus receiving
await can.stop_rx()
RS485 Bus API​
The RS485 bus supports enabling/disabling, termination resistance, transmitting, and receiving data.
- NodeJS
- Python
import AT1000 from '@ikalogic/at1000';
let testers = await AT1000.findDevices(500); // Find the device with serial number 12345
let tester = testers[0]; // Target the first detected device
let rs485 = tester.com.rs485(1); // Access RS485_2 bus on AT1000
await rs485.configure({
baud_rate: 9600,
termination_resistors: true,
enabled: true
});
// Start receiving RS485 messages
await rs485.start_rx();
// Transmit a message over RS485
await rs485.tx([0xDE, 0xAD, 0xBE, 0xEF]);
// Receive data (returns an array of bytes)
let data_rx = await rs485.rx();
// Print received bytes
console.log("RS485 Data Received:", data_rx);
// Disable RS485_2 bus
await rs485.stop_rx();
from ikalogic_at1000 import AT1000
testers = await AT1000.find_devices(500) # Find the device with serial number 12345
tester = testers[0] # Target the first detected device
rs485 = tester.com.rs485(1) # Access RS485_2 bus on AT1000
await rs485.configure({
'baud_rate': 9600,
'termination_resistors': True,
'enabled': True
})
# Start receiving RS485 messages
await rs485.start_rx()
# Transmit a message over RS485
await rs485.tx([0xDE, 0xAD, 0xBE, 0xEF])
# Receive data (returns an array of bytes)
data_rx = await rs485.rx()
# Print received bytes
print(f"RS485 Data Received: {data_rx}")
# Disable RS485_2 bus
await rs485.stop_rx()
RS232 Bus API​
The RS232 bus operates similarly to RS485 (except it does not require termination resistors).
- NodeJS
- Python
import AT1000 from '@ikalogic/at1000';
let testers = await AT1000.findDevices(500); // Find the device with serial number 12345
let tester = testers[0]; // Target the first detected device
let rs232 = tester.com.rs232(1); // Access RS232_1 bus on AT1000
// Enable RS232_1 on AT1000
await rs232.configure({
baud_rate: 9600,
enabled: true,
parity: 'N',
stop_bits: 1
});
// Start receiving RS232 messages
await rs232.start_rx();
// Transmit a message over RS232
await rs232.tx([0x01,0x02,0x03,0x04,0x05]);
// Receive data (returns a string)
let data_rx = await rs232.rx();
// Print received message
console.log("RS232 Data Received:", data_rx);
// Disable RS232_1 bus
await rs232.stop_rx();
from ikalogic_at1000 import AT1000
testers = await AT1000.find_devices(500) # Find the device with serial number 12345
tester = testers[0] # Target the first detected device
rs232 = tester.com.rs232(1) # Access RS232_1 bus on AT1000
# Enable RS232_1 on AT1000
await rs232.configure({
'baud_rate': 9600,
'enabled': True,
'parity': 'N',
'stop_bits': 1
})
# Start receiving RS232 messages
await rs232.start_rx()
# Transmit a message over RS232
await rs232.tx([0x01,0x02,0x03,0x04,0x05])
# Receive data (returns a string)
data_rx = await rs232.rx()
# Print received message
print(f"RS232 Data Received: {data_rx}")
# Disable RS232_1 bus
await rs232.stop_rx()
Summary​
The AT1000 provides CAN bus, RS485 buses and RS232 buses with advanced control features.
These interfaces allow flexible testing of communication ports with error handling for invalid configurations.