def test_sendCommand_3tubes_nonDefault(self): number_of_tubes_in_display = 3 display = SmartNixieTubeDisplay(number_of_tubes_in_display, serial_port_name=self.output_port) display.set_display_number(909) # this should equal: '$9,N,N,000,000,000,000$0,N,N,000,000,000,000$9,N,N,000,000,000,000!' read_from_port = serial.Serial( port=self.input_port, baudrate=115200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE ) display.send_command() if read_from_port.isOpen(): last_received = b'' buffer_string = b'' while last_received != b'!': last_received = read_from_port.readline(1) # print(last_received) buffer_string = buffer_string + last_received if b'!' in buffer_string: # print(buffer_string) self.assertEqual('$9,N,N,000,000,000,000$0,N,N,000,000,000,000$9,N,N,000,000,000,000!'.encode() , buffer_string) else: self.fail('read_from_port failed to open') read_from_port.close()
PACKAGE_PARENT = '..' SCRIPT_DIR = os.path.dirname( os.path.realpath( os.path.join(os.getcwd(), os.path.expanduser(__file__)))) sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT))) from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay # set number of tubes in the display numberOfTubesInDisplay = 3 # instantiate the display -- serial ports tested on Linux and Mac OS X. display = SmartNixieTubeDisplay( numberOfTubesInDisplay, '/dev/tty.usbserial-A9QHHRFJ') # '/dev/tty.usbserial-A9UD9RRV') # all the properties can be set like this: display.brightness = 255 for i in range(255): display.red = random.randint(0, 255) display.green = random.randint(0, 255) display.blue = random.randint(0, 255) # set the display number display.set_display_number(i) # random.randint(0,999)) # send the command set to the display display.send_command()
from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay except ImportError as e: import sys import os PACKAGE_PARENT = '..' SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))) sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT))) from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay # set number of tubes in the display numberOfTubesInDisplay = 3 # instantiate the display -- serial ports tested on Linux and Mac OS X. display = SmartNixieTubeDisplay(numberOfTubesInDisplay, '/dev/tty.usbserial-A9QHHRFJ') # '/dev/tty.usbserial-A9UD9RRV') # all the properties can be set like this: display.brightness = 255 for i in range(255): display.red = random.randint(0, 255) display.green = random.randint(0, 255) display.blue = random.randint(0, 255) # set the display number display.set_display_number(i) # random.randint(0,999)) # send the command set to the display display.send_command()