Sembra abbastanza ostico creare un layer per la comunicazione con dispositivi industriali via rs485.
Esempio di interfaccia python via USB port:

#!/usr/bin/env python
import minimalmodbus
import serial
m = minimalmodbus.Instrument('/dev/ttyUSB0', 2) # port name, slave address (in decimal)
m.serial.baudrate = 19200
m.serial.bytesize = 8
m.serial.stopbits = 2
m.serial.parity = serial.PARITY_NONE
data = m.read_registers(0, 2, 3) # 3 = Read holding register
print "Value A = ", data[0]
print "Value B = ", data[1]
if (data[0] < 20):
 send = 1
else:
 send = 0
m.write_register(2, send, 0, 16) # 16 = Write multiple registers
Link: http://stackoverflow.com

Di sotto un esempio invece di una implementazione su raspberryPi:

/*
 * Copyright © 2008-2010 Stéphane Raimbault 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

#include 
#include 
#include 
#include 
#include 
#include 


In cooperazione con Amazon.it

Annunci