How can I determine the hostname of a Raspberry Pi when connected from Matlab Online using deploy
Show older comments
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?
Answers (1)
aditi bagora
on 20 Oct 2023
0 votes
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.
- "HOSTNAME" variable not inherited from shell.
- Properties of raspi object.
- System function is limited in MATLAB Online.
Hope this helps!
Regards,
Aditi
Categories
Find more on MATLAB Support Package for Raspberry Pi Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!