Esempio n. 1
0
	def set_pin(self, d):
		GuideOutBase.set_pin(self, d)
		# Get current flags
		p = struct.pack('I', 0)
		flags = fcntl.ioctl(self.fileobj.fileno(), termios.TIOCMGET, p)

		# Convert four byte string to integer
		flags = struct.unpack('I', flags)[0]

		if d > 0:
			flags |= termios.TIOCM_RTS
		else:
			flags &= ~termios.TIOCM_RTS

		if d < 0:
			flags |= termios.TIOCM_DTR
		else:
			flags &= ~termios.TIOCM_DTR

		# Set new flags
		p = struct.pack('I', flags)
		fcntl.ioctl(self.fileobj.fileno(), termios.TIOCMSET, p)
Esempio n. 2
0
	def __init__(self):
		GuideOutBase.__init__(self)
		device = '/dev/ttyUSB0'
		self.fileobj = open(device, 'rw')