Layer Setting Services (LSS)¶
The LSS protocol is used to change the node id and baud rate of the target CANOpen device (slave). To change these values, configuration state should be set first by master. Then modify the node id and the baud rate. There are two options to switch from waiting state to configuration state. One is to switch all the slave at once, the other way is to switch only one slave. The former can be used to set baud rate for all the slaves. The latter can be used to change node id one by one.
Once you finished the setting, the values should be saved to non-volatile memory. Finally, you can switch to LSS waiting state.
Note
Some method and constance names are changed:
send_switch_mode_global() ==> send_switch_state_global()
network.lss.CONFIGURATION_MODE ==> network.lss.CONFIGURATION_STATE
network.lss.NORMAL_MODE ==> network.lss.WAITING_STATE
You can still use the old name, but please use the new names.
Note
Fastscan is supported from v0.8.0. LSS identify slave service is not implemented.
Examples¶
Switch all the slave into CONFIGURATION state. There is no response for the message.
network.lss.send_switch_state_global(network.lss.CONFIGURATION_STATE)
Or, you can call this method with 4 IDs if you want to switch only one slave:
vendorId = 0x00000022
productCode = 0x12345678
revisionNumber = 0x0000555
serialNumber = 0x00abcdef
ret_bool = network.lss.send_switch_state_selective(vendorId, productCode,
revisionNumber, serialNumber)
Or, you can run fastscan procedure
ret_bool, lss_id_list = network.lss.fast_scan()
Once one of sensors goes to CONFIGURATION state, you can read the current node id of the LSS slave:
node_id = network.lss.inquire_node_id()
Change the node id and baud rate:
network.lss.configure_node_id(node_id+1)
network.lss.configure_bit_timing(2)
This is the table for converting the argument index of bit timing into baud rate.
idx
Baud rate
0
1 MBit/sec
1
800 kBit/sec
2
500 kBit/sec
3
250 kBit/sec
4
125 kBit/sec
5
100 kBit/sec
6
50 kBit/sec
7
20 kBit/sec
8
10 kBit/sec
Save the configuration:
network.lss.store_configuration()
Finally, you can switch the state of the slave(s) from CONFIGURATION state to WAITING state:
network.lss.send_switch_state_global(network.lss.WAITING_STATE)
API¶
- class canopen.lss.LssMaster[source]¶
The Master of Layer Setting Services
- RESPONSE_TIMEOUT = 0.5¶
Max time in seconds to wait for response from server
- activate_bit_timing(switch_delay_ms)[source]¶
Activate the bit timing.
- Parameters:
switch_delay_ms (uint16_t) – The slave that receives this message waits for switch delay, then activate the bit timing. But it shouldn’t send any message until another switch delay is elapsed.
- configure_bit_timing(new_bit_timing)[source]¶
Set the bit timing.
- Parameters:
new_bit_timing (int) – bit timing index. 0: 1 MBit/sec, 1: 800 kBit/sec, 2: 500 kBit/sec, 3: 250 kBit/sec, 4: 125 kBit/sec 5: 100 kBit/sec, 6: 50 kBit/sec, 7: 20 kBit/sec, 8: 10 kBit/sec
- configure_node_id(new_node_id)[source]¶
Set the node id
- Parameters:
new_node_id (int) – new node id to set
- fast_scan()[source]¶
This command sends a series of fastscan message to find unconfigured slave with lowest number of LSS idenities
- inquire_lss_address(req_cs)[source]¶
- Read the part of LSS address.
VENDOR_ID, PRODUCT_CODE, REVISION_NUMBER, or SERIAL_NUMBER
- inquire_node_id()[source]¶
Read the node id. CANopen node id must be within the range from 1 to 127.
- Returns:
node id. 0 means it is not read by LSS protocol
- Return type:
- send_identify_remote_slave(vendorId, productCode, revisionNumberLow, revisionNumberHigh, serialNumberLow, serialNumberHigh)[source]¶
This command sends the range of LSS address to find the slave nodes in the specified range
- send_switch_state_global(mode)[source]¶
switch mode to CONFIGURATION_STATE or WAITING_STATE in the all slaves on CAN bus. There is no reply for this request
- Parameters:
mode (int) – CONFIGURATION_STATE or WAITING_STATE
- send_switch_state_selective(vendorId, productCode, revisionNumber, serialNumber)[source]¶
switch mode from WAITING_STATE to CONFIGURATION_STATE only if 128bits LSS address matches with the arguments. It sends 4 messages for each argument. Then wait the response from the slave. There will be no response if there is no matching slave
- Parameters:
- Returns:
True if any slave responds. False if there is no response.
- Return type: