[]【HarmonyOS HiSpark Wi-Fi IoT 套件试用连连载】第一个示例程序的烧录及运行遇到的问题及解决

阅读量0
0
3

烧录失败,权限不足
烧录时错误提示如下
  1. > Executing task in folder myfristproject: hpm run 'build' <

  2. hpm : 无法加载文件 D:nodejsnpmhpm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 abou
  3. t_Execution_Policies。
  4. 所在位置 行:1 字符: 1
  5. + hpm run 'build'
  6. + ~~~
  7. + CategoryInfo : SecurityError: (:) [],PSSecurityException
  8. + FullyQualifiedErrorId : UnauthorizedAccess
  9. The terminal process "C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -Command hpm run 'build'" terminated with exit code: 1.
复制代码

网上找到类似问题并找到解决方式:华为鸿蒙OS 尝鲜 (三)DevEco Device Tool 待完善
  • VSCode以管理员模式启动
  • 切换到命令行执行如下命令:(set-ExecutionPolicy RemoteSigned)
  1. Windows PowerShell
  2. 版权所有 (C) Microsoft Corporation。保留所有权利。

  3. 尝试新的跨平台 PowerShell https://aka.ms/pscore6

  4. PS C:Usersdavin.jiang> set-ExecutionPolicy RemoteSigned
复制代码
再次烧录,此问题解决。
安装serialport失败
烧录时提示Load serialport,@serialport/parser-readline failed.选择“y”后将自动安装相应插件。
安装报如下错误
  1. > Executing task: npm install -g serialport;npm install -g @serialport/parser-readline <

  2. (node:1616) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

  3. > @serialport/bindings@9.0.2 install C:Usersdavin.jiangAppDataRoamingnpmnode_modulesserialportnode_modules@serialportbindings
  4. > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

  5. (node:10108) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests
  6. insecure by disabling certificate verification.
  7. prebuild-install WARN install No prebuilt binaries found (target=12.18.4 runtime=node arch=x64 libc= platform=win32)

  8. C:Usersdavin.jiangAppDataRoamingnpmnode_modulesserialportnode_modules@serialportbindings>if not defined npm_config_node_gyp (node "D:_software_installnodenode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node "D:_software_installnodenode_modulesnpmnode_modulesnode-gypbinnode-gyp.js" rebuild )
  9. gyp ERR! find Python
  10. gyp ERR! find Python Python is not set from command line or npm configuration
  11. gyp ERR! find Python Python is not set from environment variable PYTHON      
  12. gyp ERR! find Python checking if "python" can be used
  13. gyp ERR! find Python - "python" is not in PATH or produced an error
  14. gyp ERR! find Python checking if "python2" can be used
  15. gyp ERR! find Python - "python2" is not in PATH or produced an error
  16. gyp ERR! find Python checking if "python3" can be used
  17. gyp ERR! find Python - "python3" is not in PATH or produced an error
  18. gyp ERR! find Python checking if the py launcher can be used to find Python 2
  19. gyp ERR! find Python - "py.exe" is not in PATH or produced an error
  20. gyp ERR! find Python checking if Python is C:Python27python.exe
  21. gyp ERR! find Python - "C:Python27python.exe" could not be run
  22. gyp ERR! find Python checking if Python is C:Python37python.exe
  23. gyp ERR! find Python - "C:Python37python.exe" could not be run
  24. gyp ERR! find Python
  25. gyp ERR! find Python **********************************************************
  26. gyp ERR! find Python You need to install the latest version of Python.
  27. gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
  28. gyp ERR! find Python you can try one of the following options:
  29. gyp ERR! find Python - Use the switch --python="C:PathTopython.exe"
  30. gyp ERR! find Python   (accepted by both node-gyp and npm)
  31. gyp ERR! find Python - Set the environment variable PYTHON
  32. gyp ERR! find Python - Set the npm configuration variable python:
  33. gyp ERR! find Python   npm config set python "C:PathTopython.exe"
  34. gyp ERR! find Python For more information consult the documentation at:
  35. gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
  36. gyp ERR! find Python **********************************************************
  37. gyp ERR! find Python
  38. gyp ERR! configure error
  39. gyp ERR! stack Error: Could not find any Python installation to use
  40. gyp ERR! stack     at PythonFinder.fail (D:_software_installnodenode_modulesnpmnode_modulesnode-gyplibfind-python.js:307:47)gyp ERR! stack     at PythonFinder.runChecks (D:_software_installnodenode_modulesnpmnode_modulesnode-gyplibfind-python.js:136:21)
  41. gyp ERR! stack     at PythonFinder.<anonymous> (D:_software_installnodenode_modulesnpmnode_modulesnode-gyplibfind-python.js:225:16)
  42. gyp ERR! stack     at PythonFinder.execFileCallback (D:_software_installnodenode_modulesnpmnode_modulesnode-gyplibfind-python.js:271:16)
  43. gyp ERR! stack     at exithandler (child_process.js:310:5)
  44. gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:322:5)
  45. gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
  46. gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
  47. gyp ERR! stack     at onErrorNT (internal/child_process.js:469:16)
  48. gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)
  49. gyp ERR! System Windows_NT 10.0.18363
  50. gyp ERR! command "D:\_software_install\node\node.exe" "D:\_software_install\node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
  51. gyp ERR! cwd C:Usersdavin.jiangAppDataRoamingnpmnode_modulesserialportnode_modules@serialportbindings
  52. gyp ERR! node -v v12.18.4
  53. gyp ERR! node-gyp -v v5.1.0
  54. gyp ERR! not ok
  55. npm ERR! code ELIFECYCLE
  56. npm ERR! errno 1
  57. npm ERR! @serialport/bindings@9.0.2 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
  58. npm ERR! Exit status 1
  59. npm ERR!
  60. npm ERR! Failed at the @serialport/bindings@9.0.2 install script.
  61. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

  62. npm ERR! A complete log of this run can be found in:
  63. npm ERR!     C:Usersdavin.jiangAppDataRoamingnpm-cache_logs2020-10-18T08_01_49_699Z-debug.log
  64. (node:13644) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests
  65. insecure by disabling certificate verification.
  66. + @serialport/parser-readline@9.0.1
  67. updated 1 package in 2.476s

  68. Terminal will be reused by tasks, press any key to close it.
复制代码
提示Python环境异常,检查发现系统未安装Python。
根据官方文档,python是在安装nodejs时勾选对话框中的选项框,自动安装必要工具(如Python、Visual Studio构建工具链)后自动安装的;但是我的PC的node环境是很早时候建好的,所以忽略了此步骤导致python环境缺失。
根据文档重新下载nodejs并安装即可。
反复提示加载serialport失败
烧录时提示加载失败(Load serialport,@serialport/parser-readline failed.
),选择全局安装插件成功后仍提示此错误,反复尝试多次仍无法解决
  1. > Executing task: hpm run 'upload' <

  2. Start flash images...

  3. Load serialport,@serialport/parser-readline failed.
  4. Please make sure system variable 'NODE_PATH' has been configured.
  5. You can run "npm config get prefix" to get prefix path, Set NODE_PATH to prefixnode_modules
  6. Do you want to install modules: serialport,@serialport/parser-readline now? y/n (default:y):
复制代码
看后面的说明才知道NODE_PATH设置问题,查看了win10系统环境变量发现已设置的变量和当前变量不一致。通过命令行查看node全局安装地址

  1. > npm config get prefix
  2. C:Usersdavin.jiangAppDataRoamingnpmnode_modules
复制代码
而查看win10 NODE_PATH环境变量值为(控制面板->系统和安全->系统->高级系统设置->环境变量->系统变量)
  1. D:_software_installnodenode_modules
复制代码
两者不一致导致明明已经全局安装成功了,其他应用却无法加载到该插件。统一更新为NODE_PATH地址即可
  1. > npm config set prefix  D:_software_installnode
  2. > npm config get prefix
  3. D:_software_installnode
复制代码
再重新烧录,未再出现此问题。
MobaXterm工具串口无法使用
目前使用MobaXterm工具串口连接成功后无法下任何命令,改用IPOP工具连接串口并勾选“Newline”后可正常输入命令了,成功完成第一个demo,log如下
  1. ready to OS start                                                                                                                  
  2. sdk ver:Hi3861V100R001C00SPC025 2020-09-03 18:10:00                                                                                 
  3. FileSystem mount ok.                                                                                                               
  4. wifi init success!                                                                                                                  
  5.                                                                                                                                     
  6. 00 00:00:00 0 132 D 0/HIVIEW: hilog init success.                                                                                   
  7. 00 00:00:00 0 132 D 0/HIVIEW: log limit init success.                                                                              
  8. 00 00:00:00 0 132 I 1/SAMGR: Bootstrap core services(count:3).                                                                     
  9. 00 00:00:00 0 132 I 1/SAMGR: Init service:0x4ae4fc TaskPool:0xfa1e4                                                                 
  10. 00 00:00:00 0 132 I 1/SAMGR: Init service:0x4ae520 TaskPool:0xfa854                                                                 
  11. 00 00:00:00 0 132 I 1/SAMGR: Init service:0x4ae630 TaskPool:0xfaa14                                                                 
  12. 00 00:00:00 0 164 I 1/SAMGR: Init service 0x4ae520 <time: 0ms> success!                                                            
  13. 00 00:00:00 0 64 I 1/SAMGR: Init service 0x4ae4fc <time: 0ms> success!                                                              
  14. 00 00:00:00 0 8 D 0/HIVIEW: hiview init success.                                                                                    
  15. 00 00:00:00 0 8 I 1/SAMGR: Init service 0x4ae630 <time: 0ms> success!                                                               
  16. 00 00:00:00 0 8 I 1/SAMGR: Initialized all core system services!                                                                    
  17. 00 00:00:00 0 64 I 1/SAMGR: Bootstrap system and application services(count:0).                                                     
  18. 00 00:00:00 0 64 I 1/SAMGR: Initialized all system and application services!                                                        
  19. 00 00:00:00 0 64 I 1/SAMGR: Bootstrap dynamic registered services(count:0).
复制代码
根据文档完成网络配置,并成功ping通百度地址
  1. AT+STARTSTA                                                                                                                        
  2. OK                                                                                                                                 
  3.                                                                                                                                                                                                                                                               
  4. AT+SCAN                                                                                                                             

  5. AT+SCAN                                                                                                                             
  6. OK                                                                                                                                 
  7.                                                                                                                                     
  8. +NOTICE:SCANFINISH                                                                                                                  
  9. AT+SCANRESULT                                                                                                                       
  10. +SCANRESULT:dx_guest,20:54:fa:67:c5:09,1,-32,2
复制代码


回帖

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。 侵权投诉
链接复制成功,分享给好友