def openPort(self):
		self.portId = os.open(self.devfile, os.O_RDONLY | os.O_NONBLOCK)
		if self.portId == 0:
			Bc.printError("Could not open " + devfile + " for read")
			return False
		else:
			return True
	def __init__(self, devfile, width):

		if width%8 != 0:
			Bc.printError(" width: " + str(width) + " is no multiple of 8 bits (1 byte)")
		else:
			self.devfile = devfile
			self.width = width
			self.nbBytes = width/8
			self.portId = 0
			ReadPort.readPortCount += 1
	def __init__(self, devfile, width, dummy=False):

		if width%8 != 0:
			Bc.printError("width: " + str(width) + " is no multiple of 8 bits (1 byte)")
		else:
			self.devfile = devfile
			self.width = width
			self.portId = 0
			self.totalBytesForTransmission = 0
			self.totalBytesTransmitted = 0
			WritePort.writePortCount += 1
			self.dummy = dummy
			self.dummyId = 0
	def openPort(self):
		self.portId = open(self.devfile, 'wb',0)
		if self.portId == 0:
			Bc.printError("Could not open " + devfile + " for write")
			return False
		else:
			#Bc.printInfo("Succesfully opened write port to " + self.devfile)

			if self.dummy:
				self.dummyId = open("./writeLog_" + str(WritePort.writePortCount), 'w')
				Bc.printInfo("Opened dummy port with id " + str(self.dummyId))

			return True