Description
end()
– ends the CAN2SER communication and clears the internal buffers. In case this CAN2SER instance uses handshaking (see constructor) this method will also send a ‘stop’-handshake messages to the peer.
Syntax
myExampleSerial.end();
Parameters
None
Returns
Nothing
Example Code
The following example creates a second CAN2SER object that can be used just like Serial for communications to the PC-CAN2SER-Monitors. The new CAN2SER object will use channel 1 whereas Serial
uses channel 0 by default.
// Create the additional global object
CAN2SER SerialPC2(&MCAN0, &BOOTLOADER_SETTING, 1, false);
void setup()
{
// Start the new serial connection
SerialPC2.begin();
// Wait for the user to open 2x can2ser-monitor windows
while (!Serial || !SerialPC2)
{
yield(); // maintain CAN traffic handling in the meanwhile
}
// Send 'hello' through both link channels
Serial.println("Hello PC. Here is Serial");
Serial2.println("Hello PC. Here is Serial2");
}
void loop ()
{
}
Notes and Warnings
See also
Example to create a serial link between two devices
Example to create an additional link to the PC
CAN2SER Class
begin()