Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added script to wirelessly transfer compiled firmware script #294

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

saadatq
Copy link

@saadatq saadatq commented Nov 6, 2024

I have added the script for wireless transfer as well as a readme file with instructions.

Please test out the script and let me know if there are any changes to be made.

@saadatq saadatq linked an issue Nov 6, 2024 that may be closed by this pull request
scripts/canflash/cantransfer.sh Outdated Show resolved Hide resolved

# Perform file transfer
echo "Transferring $BIN_FILES files to $PI_USERNAME@$HOST:$DESTINATION_PATH.."
scp -r "$BIN_FILES/*" "$PI_USERNAME@$HOST:$DESTINATION_PATH"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only want to transfer a single binary file, not the whole folder

scripts/canflash/README.md Outdated Show resolved Hide resolved
scripts/canflash/README.md Outdated Show resolved Hide resolved
scripts/canflash/README.md Outdated Show resolved Hide resolved
@saadatq saadatq requested a review from langei as a code owner November 22, 2024 03:03
@saadatq saadatq changed the title Added script to wirelessly transfer compiled firmware sccript Added script to wirelessly transfer compiled firmware script Nov 22, 2024
@saadatq
Copy link
Author

saadatq commented Nov 22, 2024

Changes have been made as requested. Let me know if you need anything else from me.

@BlakeFreer
Copy link
Contributor

BlakeFreer commented Nov 24, 2024

@CameronBeneteau can you test this on the Pi? You should be able to transfer a file from your laptop to the Pi with it

Copy link
Collaborator

@CameronBeneteau CameronBeneteau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file transfer works, but it's not as robust as we would like. Here are a few suggestions that will make it better:

I tested it with the pi and the current behaviour is as follows:

  • The command fails when the destination path is a path (since it doesn't exist on the pi)
  • The command fails when the destination path is left blank
  • If the destination path is a file, the transferred file on the pi is named to this

I would recommend changing it for the following behaviour:

  • A blank destination path will transfer the file (with the same name) to the pi's home directory
  • A destination path that is a file name (not a directory) will transfer the file with the same name to the pi's home directory
  • A destination path that is a directory will transfer the file to the same directory on the pi (this will require calling mkdir on the pi before the transfer

If you would like to test your changes and functionality on the pi please send me a message on teams and I can provide you with login information.

scripts/canflash/README.md Show resolved Hide resolved
scripts/canflash/README.md Outdated Show resolved Hide resolved
@saadatq
Copy link
Author

saadatq commented Dec 7, 2024

  • A destination path that is a file name (not a directory) will transfer the file with the same name to the pi's home directory

A little confused on what you meant by this. If the destination path is a file name is the bin file transferred to the pi's home directory or is a file on the computer with the same name transferred to the home directory?

Comment on lines 14 to 20
if [ -d "3SM4" ]; then
DESTINATION_PATH=$4
elif [ -f "3SM4" ]; then
DESTINATION_PATH="/home/$PI_USERNAME"
else
DESTINATION_PATH="/home/$PI_USERNAME"
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for home/username as the script can only transfer files within this directory. There will be a permission error if you try to transfer a file to a directory that isn't under home/username. For scp, it is assumed the destination directory is relative to /home/username.

i.e. sh cantransfer.sh test.txt username IP new-directory will transfer the file to home/username/new-directory/test.txt

scripts/canflash/cantransfer.sh Outdated Show resolved Hide resolved
scripts/canflash/cantransfer.sh Outdated Show resolved Hide resolved
@CameronBeneteau
Copy link
Collaborator

  • A destination path that is a file name (not a directory) will transfer the file with the same name to the pi's home directory

A little confused on what you meant by this. If the destination path is a file name is the bin file transferred to the pi's home directory or is a file on the computer with the same name transferred to the home directory?

Let's simplify and assume the file will not be renamed on transfer, so the destination path will always be a path.

The required behaviour will be reduced to the following:

  1. sh cantransfer test.txt macformula xxx.xxx.xxx.xxx
    Transfers test.txt to home/macformula/test.txt

  2. sh cantransfer test.txt macformula xxx.xxx.xxx.xxx random
    Transfers test.txt to home/macformula/random/test.txt

Please see #294 (comment) about home/username.

@saadatq
Copy link
Author

saadatq commented Dec 21, 2024

After testing the CAN flash transfer with the Pi, it should work as intended. Let me know if anything else is needed from me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web file transfer
3 participants