-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
#!/bin/bash | ||
|
||
usbip attach -r 192.168.100.12 -b "$USBIP_PORT" | ||
# this script has to be sourced | ||
|
||
if [[ -z "${USBIP_PORT}" || -z "${PROJECT_NAME}" ]] | ||
then | ||
echo "This project doesnt use USB/IP" | ||
return 1 | ||
fi | ||
|
||
if ls /dev/tty* | grep -q "$PROJECT_NAME" && [[ ! $(wc -l <(usbip port) | head -c 1) -eq 2 ]] | ||
then | ||
echo "Found /dev/tty$PROJECT_NAME, setting it to be used by container" | ||
DEBUG_PORT="/dev/tty$PROJECT_NAME" | ||
return 0 | ||
else | ||
echo "Didn't find existing tty USB/IP connected" | ||
rm "/dev/tty$PROJECT_NAME" | ||
fi | ||
|
||
|
||
PREV_LIST_OF_TARGETS=$(ls /dev/tty*) | ||
|
||
if usbip attach -r 192.168.100.12 -b "$USBIP_PORT" | ||
then | ||
echo "Successfully attached, linking to /dev/tty$PROJECT_NAME" | ||
# find the new target in the dev fs and symlink it to project name | ||
ln -s /dev/tty$(diff -n <(echo "$PREV_LIST_OF_TARGETS") <(ls /dev/tty*) | tail -n 1) /dev/tty"$PROJECT_NAME" | ||
DEBUG_PORT="/dev/tty$PROJECT_NAME" | ||
else | ||
echo "Failed to connect, please see below if any USB devices are available" | ||
usbip list -r 192.168.100.12 | ||
return 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#! /bin/bash | ||
minicom -b 115200 -o -D /dev/ttyACM0 | ||
minicom -b 115200 -o -D "$DEBUG_PORT" |