serial_tool.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding:utf-8 -*-
  2. import os, sys, time
  3. from TST.SerialBoard import *
  4. '''
  5. 继承自TST serial,接口类废弃
  6. '''
  7. class SerialTool():
  8. def __init__(self):
  9. self.serialBoard = SerialBoard()
  10. '''
  11. 返回当前串口板的端口号
  12. [return] str Portname
  13. '''
  14. @staticmethod
  15. def GetPortName():
  16. return SerialBoard.GetPortName()
  17. '''
  18. 打开串口
  19. [return]Bool;
  20. 返回Bool 型,说明串口打开是否成功
  21. '''
  22. def open(self):
  23. return self.serialBoard.open()
  24. '''
  25. 关闭串口
  26. [return] Bool;
  27. 返回Bool型,说明串口关闭是否成功
  28. '''
  29. def close(self):
  30. return self.close()
  31. '''
  32. 新建txt文件用以存储Log
  33. [return]str LogFilePath
  34. 返回新建的txt文件路径
  35. '''
  36. def logFilePath(self):
  37. return self.serialBoard.logFilePath()
  38. '''
  39. 打开串口打印
  40. 1)当Recordtype为 both时,串口打印写入指定文件的同时在命令行同步显示
  41. 2)当Recordtype为OSD时,只在命令行显示串口打印
  42. 3)当Recordtype为Filewrite时,串口打印不在命令行显示,只写入文件
  43. [in] str Recordtype
  44. recordtype: ‘both’,'OSD','Filewrite' 三种类型
  45. [in]str LogFilepath
  46. 当Recordtype为‘OSD’时,此参数不传参
  47. 当Recordtype为‘both’和‘Filewrite’时,必须传参,否则报错
  48. 指定串口打印写入文件的路径
  49. [Return] Bool;
  50. '''
  51. def recordLogStart(self, recordType, logFilePath):
  52. return self.serialBoard.recordLogStart(recordType, logFilePath)