How can I determine the hostname of a Raspberry Pi when connected from Matlab Online using deploy

2 次查看(过去 30 天)
Hi, I have two Raspberry Pi devices that I am using with Matlab Online, and I would like to be able to determine which one is being run from within (compiled) code run using deploy.
raspi.system only allows use of the ls commend when used from Matlab Online, so I can't do system('hostname'). I also tried hostname = getenv("HOSTNAME") but I'm not user it's working because
coder.extrinsic('disp')
hostname = getenv("HOSTNAME")
disp(sprintf('Environment variable HOSTNAME="%s"', hostname ) )
doesn't display anything on the console in Matlab Onlne.
Suggestions?

回答(1 个)

aditi bagora
aditi bagora 2023-10-20
Hello Gregory,
I understand that you are looking for a way to determine the device being used when deploying code using MATLAB Online.
The support for running system commands in MATLAB Online is limited and accessing the "HOSTNAME" environment variable using the `getenv()` function may not provide the desired result.
To address this issue, I suggest considering the following approaches:
  • Utilize the properties such as "DeviceAddress" or "BoardName" of your `raspi` object. These properties can provide information about the specific device being used.
  • Alternatively, you can switch to the MATLAB desktop application, as it offers more extensive capabilities for running system commands compared to MATLAB Online.
Please refer the following links that provides more information on the issue.
Hope this helps!
Regards,
Aditi

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Raspberry Pi Hardware 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by