Skip to content

Commit

Permalink
Examples; Replace SDSendFilesToPC with SDTransferToPC
Browse files Browse the repository at this point in the history
  • Loading branch information
chipaudette committed Oct 16, 2024
1 parent 18ee696 commit 9873e7c
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 299 deletions.
96 changes: 0 additions & 96 deletions examples/02-Utility/SD_Card/SDSendFilesToPC/SerialManager.h

This file was deleted.

174 changes: 0 additions & 174 deletions examples/02-Utility/SD_Card/SDSendFilesToPC/getFileFromTympan.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/*
SDSendFilesToPC
SDTransferToPC
Created: Chip Audette, OpenHearing, Oct 2024
Purpose: Transfer files from the SD to your PC via the Serial link. To receive the files,
you will want to use some sort of program (Python script included here) to receive the
data from the Tympan and write it to your PC's disk. The Arduino Serial Monitor will
not help you save the files. Sorry.
HOW TO USE: Obviously, you need a Tympan and you need to put an SD card in your Tympan.
Since this example will be transfering files off the SD card back to your PC, your
SD card needs some example files on it. So, with the Tympan plugged into the PC
via USB and turned on, you can use your serial communicaiton program to:
1) Send 'L' to list the files on the SD card
2) Send 'f' to ask to open a file
3) When prompted, send the filename you want (ending with a newline character)
4) Send 't' to transfer all the data bytes of the file over serial to the PC
In many cases, it is easier for your serial communication program to receive the
file if it knows how many bytes are in the file. So, in that case, youu would
insert the following step:
3.5) Send 'b' to ask for the size of the file in bytes
The file will be automatically closed when the data has all been transferred.
Purpose: Transfer files from your PC to the Tympan via the Serial link. To send and
receive the files, you'll want some sort of program (Python script included here)
to open the file on your PC and to either send the file's bytes to the Tympan or to
receive the bytes from teh Tympan. The Arduino Serial Monitor will not help you send
or receive any files. Sorry.
Requirements: Obviously, you need a Tympan and you need to put an SD card in your Tympan.
How to send a file from the Tympan's SD to your PC:
1) [Optional] Send 'L' to list the files on the SD card
2) Send 't' to start the transfer process from the Tympan to the PC
* When prompted, send the filename of the file on the SD that you want to read (as text, ending with newline character)
* Tympan will respond with the number of bytes in the file (as text, ending with newline character)
* Tympan will respond stating that the bytes will begin being transfered
* Tympan will send all of the file's bytes
How to receive a file from your PC to the Tympan's SD
1) Send 'T' to start the transfer process from the PC to the Tympan
* When prompted, send the filename you want to write (as text, ending with newline character)
* When prompted, send the length of the file in bytes (as text, ending with newline character)
* When prompted, send all of the file's bytes
* Tympan will respond with message about success or failure
If you cannot connect to the Tympan via the included Python script, be sure that
you have closed the Arduino Serial Monitor. Only one program can use your PC's
Expand All @@ -43,19 +43,19 @@
#include "SerialManager.h"

// Create the entities that we need
Tympan myTympan(TympanRev::F); //use TympanRev::D or E or F
SdFs sd; //This is the SD card. SdFs is part of the Teensy install
SDtoSerial SD_to_serial(&sd, &Serial); //transfers raw bytes of files on the sd over to Serial (part of Tympan Library)
SerialManager serialManager; //create the serial manager for real-time control (via USB)
Tympan myTympan(TympanRev::F); //use TympanRev::D or E or F
SdFs sd; //This is the SD card. SdFs is part of the Teensy install
SdFileTransfer sdFileTransfer(&sd, &Serial); //Transfers raw bytes of files from Serial to the SD card. Part of Tympan_Library
SerialManager serialManager; //create the serial manager for real-time control (via USB)


// ///////////////////////// Main setup() and loop() as required for all Arduino programs

// define the setup() function, the function that is called once when the device is booting
void setup() {
//myTympan.beginBothSerial(); //only needed if using bluetooth
delay(500); while ((millis() < 2000) && !Serial) delay(10); //stall a bit to see if Serial is connected
Serial.println("SDSendFilesToPC: setup():...");
delay(500); while ((millis() < 2000) && (!Serial)) { delay(10); } //stall a bit to see if Serial is connected
Serial.println("SDTransferToPC: setup():...");

//enable the Tympan
myTympan.enable();
Expand All @@ -69,6 +69,7 @@ void setup() {

} //end setup()


// define the loop() function, the function that is repeated over and over for the life of the device
void loop() {

Expand All @@ -80,6 +81,7 @@ void loop() {

} //end loop()


// ///////////////////////////////////////////////////////////////////////////////////////////

// This is only needed to create a dummy file on the SD card so that you have
Expand Down
Loading

0 comments on commit 9873e7c

Please sign in to comment.