chenyc
2022-07-04 e7b40bf620df67d6bb87bf4dbed5a3543182c120
初始化
10个文件已添加
223 ■■■■■ 已修改文件
.gitignore 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.timestamp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vscode/settings.json 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vscode/tasks.json 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vscode/upgrade.json 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/__MACOSX/._board.json 补丁 | 查看 | 原始文档 | blame | 历史
src/__MACOSX/._main.py 补丁 | 查看 | 原始文档 | blame | 历史
src/board.json 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/boot.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.py 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
New file
@@ -0,0 +1,29 @@
# 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
.timestamp
New file
@@ -0,0 +1 @@
create project start: 2022-07-1 13:50:11, finish: 2022-07-1 13:50:11
.vscode/settings.json
New file
@@ -0,0 +1,10 @@
{
    "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"
}
.vscode/tasks.json
New file
@@ -0,0 +1,78 @@
{
  "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}"
      }
    }
  }
}
.vscode/upgrade.json
New file
@@ -0,0 +1,10 @@
{
  "mode": "本地更新",
  "baudrate": "115200",
  "comPort": "COM18               ",
  "token": "dummy",
  "device": "dummy",
  "engine": "dummy",
  "encode": "dummy",
  "tokenList": []
}
src/__MACOSX/._board.json
Binary files differ
src/__MACOSX/._main.py
Binary files differ
src/board.json
New file
@@ -0,0 +1,36 @@
{
  "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
}
src/boot.py
New file
@@ -0,0 +1,6 @@
import utime
print('<system-debug>: System will reboot!')
utime.sleep(3)
reboot()
src/main.py
New file
@@ -0,0 +1,53 @@
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打印消息