You could in fact use the serial library, but you would need to implement some clever protocol and for some features access the corresponding UART registers directly (for the things not covered by the mbed library).
If you must stick 100% to the actual LocoNet protocol, then probably you will have to do the communication by bitbanging.
Otherwise if you can develop your own version, this protocol would for example need messages like "Hello, i want to speak now and am claiming the bus" and "Ok, i finished speaking and am releasing the bus" to be implemented. The claiming message could be a serial break event (line low for at least one serial frame length including stop bits), which can be issued via UART registers. As soon as a node wants to speak, it could set a break condition and set a timer. Then it waits for the break interrupt (break flag set). If the condition occurs too early (before end of frame according to timer value and selected baud rate), then the node knows, that another node has claimed the bus shortly earlier and will reset the break immediately and listen only. The node that wins would release the break condition too and start sending after a make period (line High for at least one frame lenght). All nodes that received a break condition interrupt, which was not their own, will go to listen only mode and will not try to send anything, before the speaking node has finished sending its packets and has sent a bus release message (unique byte frame or combination of frames not present in packet data). Then again all nodes are in idle state, where they are listening or can try sending. If the unlikely case occurs where two or more nodes claim the bus (set the break condition) at almost the same time (indistinguishable timing difference), then a second method should be in place. For this each node has to have a unique identifier (one or more bytes depending of the total number of nodes on the bus) consisting of just one zero bit. This identifier will be the first to be sent in the packet. The sending nodes compare the received identifier to their own. If it's not the same or if a frame error occured, then something must have gone wrong. So they immediately stop sending and after a random (important!) amount of time try to reclaim the bus (another break condition) ... etc.
Best regards
Neni
Hello to all. I'm doing a project where I need to check whether serial communication occurs or not a collision. I try to explain (sorry for my english): I have two devices that communicate with the serial port. The first device is the mbed and the second is a pic. Each device sends packets consist of 6 bytes (send one byte at a time). If the device 2 sends a packet and in the meantime the mbed begins to communicate the sequence of 6 bytes from the device 2 is altered. If the sequence of 6 bytes does not arrive in succession the other device can not interpret the information. Currently on the pic is already implemented the system to identify the collision and try to send the entire sequence of 6 bytes after a certain time.
The mbed should do the same thing. If the mbed identifies a collision breaks the communication and try again later to resend the entire sequence of 6 bytes.
Currently I have not found any information about it.
Thanks for your help.