Locate P4 connector on board by referring to hardware manual and short pin 1 (RS232_TX_1) and pin 2(RS232_RX_1) to echo the transmitted data back to board. Short Type the following code in target board and save it with extension .py .
To test this python code, need to add the pyserial package in root file system. in nor rootfs image, this pyserial package was not included. This will be included in sdcard image.
viuart4.py
'''Copy and Paste the python code on to your vi editorand save and exit the editor.You can also use any other editor from your host PCto write the code with .py extension and transfer thepython code file to the RuggedBoard. To transfer filesfrom host PC to RB will be show in the later upcomingsection named as "Transfering files from host PC to RB"'''import timeimport serialser = serial.Serial( port='/dev/ttyS4', baudrate=9600, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_TWO, bytesize=serial.SEVENBITS)ser.isOpen()print ('Enter your commands below.\r\nInsert "exit" to leave the application.')input=1while1:input=raw_input(">> ")ifinput=='exit': ser.close()exit()else: ser.write(input+'\r\n') out ='' time.sleep(1)while ser.inWaiting()>0: out += ser.read(1)if out !='':print">>"+ out
To execute the code use the below command and enter anything for loopback test.
In rugged board having 3 LED's, here blinking the one LED(PC13) using below python example code.following code in target board and save it with extension .py .
To execute the code use the below command then on board yellow LED(near to ethernet port) starts blinking.
python3led_blinky.py
Below code is for blinking the 3 LED's (PC13, PC17, PC19).
viblinky_leds.py
#!/usr/bin/pythonimportsys,timegpio1_name="PC13"gpio1_number="77"gpio2_name="PC17"gpio2_number="81"gpio3_name="PC19"gpio3_number="83"OUT="out"IN="in"HIGH="1"LOW="0"sys_path="/sys/class/gpio/"defgpExport(gpio_number):f=open(sys_path+"export","w")f.write(gpio_number)f.close()defgpUnexport(gpio_number):f=open(sys_path+"unexport","w")f.write(gpio_number)f.close()defsetDir(gpio_name,dir):f=open(sys_path+gpio_name+"/direction","w")f.write(dir)f.close()defsetValue(gpio_name,val):f=open(sys_path+gpio_name+"/value","w")f.write(val)f.close()definitLed(gpio_name,gpio_number):gpExport(gpio_number)setDir(gpio_name,OUT)setValue(gpio_name,HIGH)defexit(gpio_name,gpio_number):setValue(gpio_name,HIGH)gpUnexport(gpio_number)defledOff(gpio_name):setValue(gpio_name,HIGH)defledOn(gpio_name):setValue(gpio_name,LOW)initLed(gpio1_name,gpio1_number)initLed(gpio2_name,gpio2_number)initLed(gpio3_name,gpio3_number)try:whileTrue:ledOn(gpio1_name)print("LED1 is ON")ledOff(gpio2_name)ledOff(gpio3_name) time.sleep(0.2)ledOff(gpio1_name)ledOn(gpio2_name)print("LED2 is ON")ledOff(gpio3_name) time.sleep(0.2)ledOff(gpio1_name)ledOff(gpio2_name)ledOn(gpio3_name)print("LED3 is ON") time.sleep(0.2)exceptKeyboardInterrupt:exit(gpio1_name,gpio1_number)exit(gpio2_name,gpio2_number)exit(gpio3_name,gpio3_number)
To execute the code use the below command then on board, all 3LED's(near to ethernet port) starts blinking.