The Torizon IDE extensions in VS Code is broken on any platform which doesn’t have the -I flag on the hostname command. When starting up, it sets the computer’s hostname to an empty string, and connecting to devices does not work. It doesn’t make use of NodeJS’s platform independent network stuff which would simplify it a great deal.
Here’s some code which uses the platform independent APIs. I’ve just tested this on Linux but it should theoretically work on any OS.
async function getHostIp() {
const overwriteHostIp = ExtensionUtils_1.ExtensionUtils.fromSettings("overwriteHostIp");
if (overwriteHostIp != null && overwriteHostIp.trim() !== "") {
ExtensionUtils_1.ExtensionUtils.writeln("User defined host IP address found");
ExtensionUtils_1.ExtensionUtils.Global.HOST_IP = overwriteHostIp.trim();
ExtensionUtils_1.ExtensionUtils.writeln(`Host IP address OK "${ExtensionUtils_1.ExtensionUtils.Global.HOST_IP}"`);
} else {
ExtensionUtils_1.ExtensionUtils.writeln("Resolving host IP address ...");
const interfaces = os.networkInterfaces();
let hostIp = '';
for (const ifaceName of Object.keys(interfaces)) {
for (const iface of interfaces[ifaceName]) {
// Skip over internal (i.e. 127.0.0.1) and non-IPv4 addresses
if (iface.family === 'IPv4' && !iface.internal) {
hostIp = iface.address;
break;
}
}
if (hostIp) {
break;
}
}
if (hostIp) {
ExtensionUtils_1.ExtensionUtils.Global.HOST_IP = hostIp.trim();
ExtensionUtils_1.ExtensionUtils.writeln(`Host IP address OK "${ExtensionUtils_1.ExtensionUtils.Global.HOST_IP}"`);
} else {
ExtensionUtils_1.ExtensionUtils.writeln("Could not determine host IP address");
}
}
}
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
The issue you’re describing with the Torizon IDE extension in Visual Studio Code seems to be related to the use of the hostname command with the -I flag, which is not available on all platforms. This can lead to problems when the extension tries to set the computer’s hostname to an empty string, causing connectivity issues with devices.
The provided code snippet offers a solution by using NodeJS’s platform-independent APIs to determine the host IP address. This approach checks the network interfaces available on the system and selects the first non-internal IPv4 address it finds. This method should work across different operating systems, as it doesn’t rely on platform-specific command-line tools.
If you’re experiencing this issue, you might consider implementing a similar approach in your setup or checking if there’s an update or patch for the Torizon IDE extension that addresses this problem. If the issue persists, reaching out to Toradex support or the community forums for further assistance might be beneficial.
Please, also check if these links can help you solve your problem:
Arch Linux x64. There are other parts that are not compatible with non-debian systems, but this is one that makes the extension unusable on non-debian systems.
I see that makes sense then. After discussing with our team, we only officially support our extension on Ubuntu and Debian systems. So this result is somewhat expected. They mentioned manually setting your IP via the setting described here could help: Workspace - Settings | Toradex Developer Center
That said we can’t guarantee you won’t have any other issues with the extension related to the Linux distro you are using. Since we only extensively test our extension on Ubuntu and Debian.