| New file |
| | |
| | | # Logs |
| | | logs |
| | | *.log |
| | | npm-debug.log* |
| | | yarn-debug.log* |
| | | yarn-error.log* |
| | | pnpm-debug.log* |
| | | lerna-debug.log* |
| | | |
| | | node_modules |
| | | dist |
| | | dist-ssr |
| | | *.local |
| | | |
| | | # Editor directories and files |
| | | .idea |
| | | .DS_Store |
| | | *.suo |
| | | *.ntvs* |
| | | *.njsproj |
| | | *.sln |
| | | *.sw? |
| | | |
| | | release |
| | | upgrade |
| | | .vscode/.debug.env |
| | | package-lock.json |
| | | pnpm-lock.yaml |
| | | yarn.lock |
| New file |
| | |
| | | create project start: 2022-07-1 13:50:11, finish: 2022-07-1 13:50:11 |
| New file |
| | |
| | | { |
| | | "haasStudio.name": "test_demo", |
| | | "haasStudio.hardware.board": "haas506", |
| | | "haasStudio.appType": "python", |
| | | "haasStudio.solutionName": "helloworld", |
| | | "haasStudio.projectDir": "c:\\Users\\ThinkPad\\Desktop\\hass506\\test_demo", |
| | | "haasStudio.comPort": "COM3", |
| | | "haasStudio.hardware.baudrate": 115200, |
| | | "haasStudio.pythonAdvanced": "disable" |
| | | } |
| New file |
| | |
| | | { |
| | | "version": "2.0.0", |
| | | "tasks": [ |
| | | { |
| | | "label": "haas-studio: Config", |
| | | "type": "shell", |
| | | "command": "aos", |
| | | "args": [ |
| | | "make", |
| | | "test_demo@haas506", |
| | | "-c", |
| | | "config" |
| | | ], |
| | | "presentation": { |
| | | "focus": true |
| | | } |
| | | }, |
| | | { |
| | | "label": "haas-studio: Make", |
| | | "type": "shell", |
| | | "command": "aos", |
| | | "args": [ |
| | | "make" |
| | | ], |
| | | "presentation": { |
| | | "focus": true |
| | | } |
| | | }, |
| | | { |
| | | "label": "haas-studio: Burn", |
| | | "type": "shell", |
| | | "command": "aos", |
| | | "args": [ |
| | | "burn" |
| | | ], |
| | | "presentation": { |
| | | "focus": true |
| | | } |
| | | }, |
| | | { |
| | | "label": "haas-studio: Serial Monitor", |
| | | "type": "shell", |
| | | "command": "aos", |
| | | "args": [ |
| | | "monitor", |
| | | "COM3", |
| | | "115200" |
| | | ], |
| | | "presentation": { |
| | | "focus": true, |
| | | "panel": "dedicated" |
| | | } |
| | | }, |
| | | { |
| | | "label": "haas-studio: Clean", |
| | | "type": "shell", |
| | | "command": "aos", |
| | | "args": [ |
| | | "make", |
| | | "clean" |
| | | ], |
| | | "presentation": { |
| | | "focus": true |
| | | } |
| | | }, |
| | | { |
| | | "label": "dummy_aos3.3.0", |
| | | "command": "pwd" |
| | | } |
| | | ], |
| | | "windows": { |
| | | "options": { |
| | | "env": { |
| | | "PATH": "C:\\ProgramData\\aos\\miniconda3;C:\\ProgramData\\aos\\miniconda3\\Scripts;C:\\ProgramData\\aos\\miniconda3\\Library\\bin;${env:PATH}" |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | { |
| | | "mode": "本地更新", |
| | | "baudrate": "115200", |
| | | "comPort": "COM18 ", |
| | | "token": "dummy", |
| | | "device": "dummy", |
| | | "engine": "dummy", |
| | | "encode": "dummy", |
| | | "tokenList": [] |
| | | } |
| New file |
| | |
| | | { |
| | | "name": "haas506", |
| | | "version": "1.0.0", |
| | | "io": { |
| | | "serial1": { |
| | | "type": "UART", |
| | | "port": 0, |
| | | "dataWidth": 8, |
| | | "baudRate": 9600, |
| | | "stopBits": 1, |
| | | "flowControl": "disable", |
| | | "parity": "none" |
| | | }, |
| | | "serial2": { |
| | | "type": "UART", |
| | | "port": 1, |
| | | "dataWidth": 8, |
| | | "baudRate": 9600, |
| | | "stopBits": 1, |
| | | "flowControl": "disable", |
| | | "parity": "none" |
| | | }, |
| | | "serial3": { |
| | | "type": "UART", |
| | | "port": 2, |
| | | "dataWidth": 8, |
| | | "baudRate": 115200, |
| | | "stopBits": 1, |
| | | "flowControl": "disable", |
| | | "parity": "none" |
| | | } |
| | | }, |
| | | "debugLevel": "ERROR", |
| | | "repl": "enable", |
| | | "replPort": 3 |
| | | } |
| New file |
| | |
| | | import utime |
| | | |
| | | |
| | | print('<system-debug>: System will reboot!') |
| | | utime.sleep(3) |
| | | reboot() |
| New file |
| | |
| | | import utime |
| | | from driver import UART |
| | | # 串口实例化 |
| | | #ttl串口 |
| | | uart0 = UART() |
| | | uart0.open("serial1") |
| | | #rs232串口 |
| | | uart1 = UART() |
| | | uart1.open("serial2") |
| | | |
| | | if __name__ == '__main__': |
| | | print("Initial start") |
| | | utime.sleep(1) |
| | | while True: |
| | | # 创建一个writeBuf字节数组,用于串口读 |
| | | resultSize = 0 |
| | | result = bytearray(50) # RS232串口接收数据 |
| | | resultSize = uart1.read(result) |
| | | print("read data length", resultSize) |
| | | print("read data",result) |
| | | print("read data",result.decode('utf-8')) |
| | | utime.sleep_ms(1000) |
| | | if(resultSize > 0): |
| | | # TTL串口发送接收到的数据 |
| | | strResult=result.decode('utf-8') |
| | | list= strResult.split(',') |
| | | print(list[2]) |
| | | if(len(list[2])==8): |
| | | # 转换结果方便计算 |
| | | tzNumber=float(list[2]) |
| | | # 计算体重+0.1kg |
| | | tzNumber=tzNumber+0.1 |
| | | #转回string类型 |
| | | tzStr=str(tzNumber) |
| | | #构建一个8位空字符串 |
| | | lsjg=' ' |
| | | #构建一个临时变量 |
| | | qianStr="" |
| | | #拼凑原来的空字符 |
| | | for x in range(len(list[2])-len(tzStr)): |
| | | qianStr+=" " |
| | | #拼接计算后的list[2] |
| | | list[2]=qianStr+tzStr |
| | | #转为原始数据字符串 |
| | | list2=",".join(list) |
| | | print('new result',list2) |
| | | #转成bytearray发送到串口 |
| | | sendByarray=bytearray(list2.encode("utf-8")) |
| | | uart0.write(sendByarray) |
| | | utime.sleep_ms(1000) |
| | | #ST,GS, 17.5,kg .encode() |
| | | |
| | | print("this is usb reply") # usb口作为交互口,利用print打印消息 |