We already showed you in a previous post how to use a Yocto-Serial to decode Wiegand messages over USB, for instance to interface an RFID reader. And as we could have guessed, someone asked a bit later if the reverse was possible as well: can we send Wiegand messages using the same USB interface? The answer is yes, it is now possible as well. Let's see how to proceed...
First get back to the basics to understand how to properly connect the Yocto-Serial for use in Wiegand mode. As explained in the first post on this topic, a Wiegand link is made of two data wires, in addition to the ground wire. But contrarily to a usual serial line, the two data lines are not for bidirectional communication: one wire is used only to send "1" whereas the other is used only to send "0". Both wires are kept at 5V when idle, and the emitter pulls down one line or the other to send each bit, according to specified timings.
Although there is usually only one emitter and one receiver on a Wiegand link, nothing prevents to use it as a bus: there could be more nodes listening to messages, and messages do not have to originate from a single node. We only have to put all emitters and receivers in parallel on D0 and D1 wires. For instance, here is how a Yocto-Serial could be connected on a Wiegand link between a RFID reader and an electronic lock:
Connecting a Yocto-Serial on a Wiegand link
In this way, you can record all messages - eg. tag identifiers - sent by the RFID reader to the electronic lock. But from now on, if you update the firmware of your Yocto-Serial, the same setup will allow you to send Wiegand messages on the bus, to open the lock. This makes it possible for instance to use other access control methods, such as single-use QR code or an up-to-date NFC reader compatible with mobile phones, without having to change the lock infrastructure itself: the Yocto-Serial will simply emulate the message sent by a standard RFID tag corresponding to the authorized person.
Extending a Wiegand system using a Yocto-Serial as gateway
In the same way as for incoming messages, the Yocto-Serial offers a Wiegand ASCII mode where you send any message as a string of zeros and ones corresponding to the desired Wiegand message, and that can be used for any type of encoding used on the system. It also offers a more comfortable support for Wiegand-26 et Wiegand-34, allowing to send 3/4 bytes, which will be automatically converted to binary, adding parity bits at the beginning and end of each message.
YSerialPort wiegand = YSerialPort.FindSerialPort("myAccessSystem");
// Emit tag ID F0137F (parity bits will be added automatically)
// Emit same ID, using the free binary encoding
By the way, you have probably noticed the complete lack of cryptography or any other form of signature in Wiegand messages. Knowing this, be aware that the security of a Wiegand system relies entirely on the physical security of the communication line. If someone ever get a chance to connect a Yocto-Serial on your Wiegand link, he will be able to make whatever he wants. So make sure to bury all cables in the wall...