Libnodave is a library to exchange data with Siemens PLCs.
The PLCs of the S7-300 and S7-400 family have a so called MPI (multipoint) interface. This interface is mainly used to program the device, but can also be used to read and write data from and to the PLC. The physical layer of the MPI interface is a two wire line operated with differential voltage like RS422 or RS485.
More than two devices can be connected to that line. The data flow is bidirectional. The baud rate is normally 187.5 kBaud, but you may select others. Because no standard PC hardware can do these baud rates, you cannot use a simple signal level converter. You will allways need an adapter from Siemens or another vendor. These adapters are "intelligent" devices built around some microprocessor. They talk MPI to the PLC and something else to your PC. The rest of this document is about this "something else".
1. Initialize the serial interface:fd=setPort("/dev/ttyS1","19200",'O')
2. Initialize a daveInterfacedi = daveNewInterface(fd,"Some name")
3. Initialize the MPI adaptererror=daveInitAdapter(di))
4. Initialize a daveConnectiondc = daveNewConnection(di,2);
5. Connect to a PLC with a given MPI addressdaveConnectPLC(dc);
6. Exchange data with that PLCdaveReadBytes(dc,daveFlags,0,0,24);
7. Disconnect from the PLCdaveDisconnectPLC(dc);
8. Disconnect from the Adapter daveDisconnectAdapter(di);