Example #1
0
def listFiles():
    global fileLength
    global fileName

    if fileName is None:  #set impossible
        fileName = "spoogert"
        fileLength = 1000000000
    setPort.serialOpenCheck()  #open serial connection send AT to check
    listCommand = "AT#LSCRIPT\r\n"
    print "Listing current files:"
    print "Sending: " + listCommand
    setPort.telitPort.flush()
    setPort.telitPort.write(listCommand)
    input = setPort.getReply()
    foundFile = "false"
    for line in input:
        print line
        if "#LSCRIPT: \"%s\",%i" % (fileName, fileLength) in line:
            print "*******************************FOUND FILE->" + fileName
            foundFile = "true"
    if foundFile == "true":
        print "#########################################"
        print "FILE: " + fileName + " is stored on Telit.."
        print "#########################################"

    setPort.serialClose()
    return input
Example #2
0
def listFiles():
	global fileLength
	global fileName
	
	if fileName is None:				#set impossible
		fileName="spoogert"
		fileLength=1000000000
	setPort.serialOpenCheck()			#open serial connection send AT to check
	listCommand= "AT#LSCRIPT\r\n" 
	print "Listing current files:"
	print "Sending: " + listCommand
	setPort.telitPort.flush()
	setPort.telitPort.write(listCommand)
	input = setPort.getReply()
	foundFile="false"
	for line in input:
		print line
		if "#LSCRIPT: \"%s\",%i" % (fileName,fileLength) in line:
			print "*******************************FOUND FILE->" +fileName
			foundFile="true"	
	if foundFile == "true":
		print "#########################################"
		print "FILE: " +fileName + " is stored on Telit.."
		print "#########################################"
	
	setPort.serialClose()
	return input
Example #3
0
def deleteFile():
	global fileLength
	global fileName
	
	setPort.serialOpenCheck()				#open serial connection send AT to check
	deleteCommand= "AT#DSCRIPT=%s\r\n" % (fileName)
	if ".py" in fileName:
		print "\nDELETING .py file:"
		#delete both files .py and .pyo
		print "Sending: " + deleteCommand
		setPort.telitPort.flush()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName
				break	
			elif "ERROR" in lines:
				print "didn't find .py file: " +fileName
				print lines
				break
		#delete .pyo
		print "\nDELETING .pyo file:"
		deleteCommand= "AT#DSCRIPT=%so\r\n" % (fileName) #add 'o' for pyo
		print "Sending: " + deleteCommand
		setPort.telitPort.flushInput()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName+"o"
				break
			elif "ERROR" in lines:
				print "didn't find .pyo file: " +fileName
				print lines
				break
	else:
		print "\nDELETING file:"
		#delete file
		print "Sending: " + deleteCommand
		setPort.telitPort.flush()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName
				break	
			elif "ERROR" in lines:
				print "didn't find .py file: " +fileName
				print lines
				break

	setPort.serialClose()
Example #4
0
def deleteFile():
	global fileLength
	global fileName
	
	setPort.serialOpenCheck()				#open serial connection send AT to check
	deleteCommand= "AT#DSCRIPT=%s\r\n" % (fileName)
	if ".py" in fileName:
		print "\nDELETING .py file:"
		#delete both files .py and .pyo
		print "Sending: " + deleteCommand
		setPort.telitPort.flush()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName
				break	
			elif "ERROR" in lines:
				print "didn't find .py file: " +fileName
				print lines
				break
		#delete .pyo
		print "\nDELETING .pyo file:"
		deleteCommand= "AT#DSCRIPT=%so\r\n" % (fileName) #add 'o' for pyo
		print "Sending: " + deleteCommand
		setPort.telitPort.flushInput()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName+"o"
				break
			elif "ERROR" in lines:
				print "didn't find .pyo file: " +fileName
				print lines
				break
	else:
		print "\nDELETING file:"
		#delete file
		print "Sending: " + deleteCommand
		setPort.telitPort.flush()
		setPort.telitPort.write(deleteCommand)
		input = setPort.getReply()
		for lines in input:
			if "OK" in lines:
				print "FOUND AND DELETED:" +fileName
				break	
			elif "ERROR" in lines:
				print "didn't find .py file: " +fileName
				print lines
				break

	setPort.serialClose()
Example #5
0
def writeFile():
    global fileInput
    global fileLength
    global fileName

    print "writing file:"
    print fileName
    print fileLength

    if int(fileLength) > 20000:
        print "#### FILE TOO BIG 20000 byte max #####"
        sys.exit(1)
    writeCommand = "AT#WSCRIPT=\"%s\",%i,0\r" % (fileName, fileLength)
    print "Sending:" + writeCommand
    setPort.serialOpenCheck()  #open serial connection send AT to check
    setPort.telitPort.flushInput()  #get rid of junk
    time.sleep(1)
    setPort.telitPort.write(writeCommand)
    time.sleep(1)
    input = setPort.getReply()  #from setPort
    if ">>>" not in input:
        print "didn't get >>>??"
        print input
        sys.exit(1)
    print "START FILE#########"
    lineMarker = 0
    for line in fileInput:
        try:  #two from back is /n/l
            if (line[-1:] == "\r\n"):
                writeLine = line
            #it is somthing else append \r\n
            else:
                writeLine = line  #[:-1] + "\r\n"
            #write out to port
            setPort.telitPort.write(writeLine)
            ##print what we wrote
            #print "%i: %s" % (lineMarker,writeLine)
            lineMarker += 1
        #	time.sleep(.1) #sleep a bit to see the line
        except setPort.serial.serialutil.SerialTimeoutException:
            print "serial timed out on line " + lineMarker
            setPort.serialClose()
            sys.exit(1)
    input = setPort.getReply()
    for line in input:
        if "OK\r\n" in line:
            print "loaded OK"
            break
    else:
        print input
    setPort.telitPort.flush()
    print "END FILE###########"
Example #6
0
def writeFile():
	global fileInput
	global fileLength
	global fileName
	
	print "writing file:"
	print fileName
	print fileLength

	if int(fileLength)>7200:
		print "#### FILE TOO BIG 7200 byte max #####"
		sys.exit(1)		
	writeCommand= "AT#WSCRIPT=%s,%i\r\n" % (fileName,fileLength)
	print "Sending:" + writeCommand
	setPort.serialOpenCheck()			#open serial connection send AT to check
	setPort.telitPort.flushInput()			#get rid of junk
	setPort.telitPort.write(writeCommand)
	input = setPort.getReply()			#from setPort
	if ">>>" not in input:
		print "didn't get >>>??"
		print input		
		sys.exit(1)
	print"START FILE#########"
	lineMarker=0
	for line in fileInput:
		try:	#two from back is /n/l
			if(line[-1:] == "\r\n"):
				writeLine=line
			#it is somthing else append \r\n
			else:
				writeLine=line#[:-1] + "\r\n"
			#write out to port
			setPort.telitPort.write(writeLine)
			##print what we wrote
			#print "%i: %s" % (lineMarker,writeLine)
			lineMarker+=1
		#	time.sleep(.1) #sleep a bit to see the line
		except setPort.serial.serialutil.SerialTimeoutException:
			print "serial timed out on line " + lineMarker	
			setPort.serialClose()
			sys.exit(1)
	input = setPort.getReply()
	for line in input:
		if "OK\r\n" in line:
			print "loaded OK"
			break
	else:
		print input
	setPort.telitPort.flush()
	print"END FILE###########"
Example #7
0
def runScript():
    global fileName
    setPort.serialOpenCheck()  #open serial connection send AT to check
    readCommand = "AT#EXECSCR\r\n"

    print "Sending: " + readCommand
    setPort.telitPort.flush()
    setPort.telitPort.write(readCommand)
    input = setPort.getReply()
    print "STATUS:"
    for line in input:
        print line
        if line == 'OK':
            break
    setPort.serialClose()
Example #8
0
def enableScript():
	global fileName
	setPort.serialOpenCheck()			#open serial connection send AT to check
	if fileName == None:
		readCommand = "AT#ESCRIPT?\r\n" 
	else:
		readCommand = "AT#ESCRIPT=\"%s\"\r\n" % (fileName)
		print "SETTING MAIN() SCRIPT AS: " + fileName
	print "Sending: " + readCommand
	setPort.telitPort.flush()
	setPort.telitPort.write(readCommand)
	input = setPort.getReply()
	print "STATUS:"
	for line in input:
		print line
	setPort.serialClose()
Example #9
0
def enableScript():
    global fileName
    setPort.serialOpenCheck()  #open serial connection send AT to check
    if fileName == None:
        readCommand = "AT#ESCRIPT?\r\n"
    else:
        readCommand = "AT#ESCRIPT=\"%s\"\r\n" % (fileName)
        print "SETTING MAIN() SCRIPT AS: " + fileName
    print "Sending: " + readCommand
    setPort.telitPort.flush()
    setPort.telitPort.write(readCommand)
    input = setPort.getReply()
    print "STATUS:"
    for line in input:
        print line
    setPort.serialClose()
Example #10
0
def writeFile():
	global fileInput
	global fileLength
	global fileName
	
	print "writing file:"
	print fileName
	print fileLength

	# don't know why this limitation (maybe crucial, don't really know, let's try)
	# ok, big filesize MAY be a problem, but it's solved.
	#  point is that after each chunk we should wait some time to get device to think a bit
	#  or it returns ERROR
	#if int(fileLength)>MAXFILESIZE:
	#	print "#### FILE TOO BIG " + str(MAXFILESIZE)  + " byte max #####"
	#	sys.exit(1)		
	writeCommand= "AT#WSCRIPT=%s,%i\r\n" % (fileName,fileLength)
	print "Sending:" + writeCommand
	setPort.serialOpenCheck()			#open serial connection send AT to check
	setPort.telitPort.flushInput()			#get rid of junk
	setPort.telitPort.write(writeCommand)
	input = setPort.getReply()			#from setPort
	if ">>>" not in input:
		print "didn't get >>>??"
		print input		
		sys.exit(1)
	print"START FILE#########"
	lineMarker=0
	chunk_sent_size=0
	for line in fileInput:
		# + because I don't want to worry if python thinks \n and \r are counted symbols or not
		chunk_sent_size = chunk_sent_size + len(line) + 2
		#print "chunk_sent_size: " + str(chunk_sent_size)
		try:	#two from back is /n/l
			if(line[-1:] == "\r\n"):
				writeLine=line
			#it is somthing else append \r\n
			else:
				writeLine=line#[:-1] + "\r\n"
			#write out to port
			setPort.telitPort.write(writeLine)
			##print what we wrote
			#print "%i: %s" % (lineMarker,writeLine)
			lineMarker+=1
		#	time.sleep(.1) #sleep a bit to see the line
		except setPort.serial.serialutil.SerialTimeoutException:
			print "serial timed out on line " + lineMarker	
			setPort.serialClose()
			sys.exit(1)
		if (chunk_sent_size > CHUNKSIZE):
			time.sleep(CHUNK_SLEEP_DELAY)
			chunk_sent_size = 0
			print "Allow device to digest data for " + str(CHUNK_SLEEP_DELAY) + " sec."
	input = setPort.getReply()
	for line in input:
		if "OK\r\n" in line:
			print "loaded OK"
			break
	else:
		print input
	setPort.telitPort.flush()
	print"END FILE###########"
Example #11
0
def TESTSERIAL():
	setPort.serialOpenCheck()			#open serial connection send AT to check
	setPort.serialClose()
Example #12
0
def TESTSERIAL():
    setPort.serialOpenCheck()  #open serial connection send AT to check
    setPort.serialClose()