serie.py 942 Bytes
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/python
import sys, os, subprocess, random, time, datetime
timeout_hardware=30;
from multiprocessing import Process
import time
inject = False
import serial


def watchdog_pro (serie):
  print ("Watchdog ini")
  os.system ("tools/watchset "+`timeout_hardware`)
  serie.write ("Watchdog timeout value: "+`timeout_hardware`+"\r\n")
  while True :
        time.sleep (timeout_hardware-1)
        w=open("/dev/watchdog0","r+")
	serie.write ("Watchdog timeout value: "+`timeout_hardware`+"\r\n")


def configurate_serie():
	#os.system("sudo stop ttyS0")
	Puerto="/dev/ttyS0"
	try:
	   serie = serial.Serial(Puerto, 115200)
	   serie.timeout=1;
   
	except serial.SerialException:
	   #-- Error al abrir el puerto serie
	   sys.stderr.write("Error al abrir puerto (%s)\n" % Puerto)
	return serie


def main():
	
       configurate_serie()	
	
##############################################################################
main()