Skip to content

Commit

Permalink
fix: 修复串口二次打开后的权限问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fishros committed Sep 23, 2024
1 parent 5c0508e commit 8439676
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tool/esp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ def config_board(self, key: str, value: str, port='/dev/ttyUSB0', baudrate=11520
return result

def write_flash(self, serial_port, baud_rate, chip, firmware_image,cwd=None,flash_freq='40m'):
try:
ser = serial.Serial()
ser.port = serial_port
ser.baudrate = 115200
ser.rts = False # fix restart board
ser.open()
except Exception as e:
e_str = str(e)
if e_str.find('Permission')>0 or e_str.find('权限')>0:
self.logger(f'[警告]串口打开异常,请检查设备权限,手动单次添加可使用命令:\n sudo chmod 666 {serial_port}\n彻底解决:\n sudo usermod -a -G dialout $USER')
return False
# try:
# ser = serial.Serial()
# ser.port = serial_port
# ser.baudrate = 115200
# ser.rts = False # fix restart board
# ser.open()
# except Exception as e:
# e_str = str(e)
# print(e_str)
# if e_str.find('Permission')>0 or e_str.find('权限')>0:
# self.logger(f'[警告]串口打开异常,请检查设备权限,手动单次添加可使用命令:\n sudo chmod 666 {serial_port}\n彻底解决:\n sudo usermod -a -G dialout $USER')
# return False
try:
if not cwd:
cwd = os.environ['FISHBOT_CURRENT_DIR']
Expand Down

0 comments on commit 8439676

Please sign in to comment.