Can Get Set Configuration
Syntax
long canGetConfiguration(long channel, canSettings settings);
long canSetConfiguration(long channel, canSettings settings);
Function
The CAN controller parameters can be set or read. canSetConfigurationperforms an automatic reset of the CAN controller.
Parameters
Channel The CAN channel.
structcanSettings {float baudrate; //in bit/sunsigned char tseg1, tseg2; //length of the time segments 1 and 2 in time quantaunsigned char sjw; //sync jump width in time quantaunsigned char sam; //number of sampling points (1 or 3)unsigned int flags; //see description below}; Flags forcanGetConfiguration: Flags forcanSetConfiguration:
Return Values
1 = success0 = error
int ret;int channel = 1;canSettings settings;settings.baudrate = 1000000;settings.tseg1=5;settings.tseg2=2;settings.sjw=2;settings.sam=1;settings.flags = 0;write("Set 1 MB");ret = canSetConfiguration(channel, settings);ret = canGetConfiguration(channel, settings);if (ret){write("Settings: baud= %f, tseg1 = %d, tseg2= %d, sjw = %d, sam = %d, flags = 0x%x",settings.baudrate, settings.tseg1, settings.tseg2, settings.sjw, settings.sam, settings.flags);}