MTP Responder Contribution

@Fluxanode
two answers here
- do not use Sdfat.h but only SD.h, which since recently uses Sdfat internally.
- teensy is a mtp responder and therefore has no control in what PC (the master or initiator) knows about the existing files.
in particular, when teensy is adding files (during data acquisition) , PC will not know about this. The MTP protocol is designed to transfer existing files and not to monitor a device.
Under normal circumstances, Teensy should only reply to PC requests. However, there are some possibilities that teensy informs PC that situation has changed. One of this options is to reset completely the MTP. this is done in mtp-basic by receiving the letter 'r' from the PC.

two comments:
better not to call mtpd.loop() while in acquisition mode, it is useless. better to call this function only when acquisition is stopped.
you may check with mtp-logger.ino how this could be done.
 
Thanks again for the help, let me mull this over.
I'm sure I'll have more questions, thanks for your patience with my rookie questions.

BTW where is the mtpd_loop() in your source code?
Can I call mtpd_loop() from a menu item?
Does it need to be in a loop and how does it exit when finished?
Is there a method to send the reset 'r' from the program rather than serial monitor?
 
Last edited:
@WMXZ
BTW where is the mtpd_loop() in your source code?
Can I call mtpd_loop() from a menu item?
Does it need to be in a loop and how does it exit when finished?
Is there a method to send the reset 'r' from the program rather than serial monitor?
 
@WMXZ - Is there a method to send the reset 'r' from the program rather than serial monitor?

I found my answer to that question... mtpd.send_DeviceResetEvent() Where is this function located?
 
Last edited:
mtp.loop() is in the MTP.cpp file and similar to loop() must be called continuously to service each PC mtp request.

mtp.loop() contains a mtp protocol interpreter. that's all.
where you loop you call it, its up to you. but to service PC MTP request you must call it continuously. If there are no requests, mtp.loop() simply exits.

Is there a method to send the reset 'r' from the program rather than serial monitor?
PC sends 'r' (or any command to tell Teensy to send reset event) and teensy sends reset event over MTP back to PC.

of course, on PC you can unmount/mount the MTP portable device to do the same. But this is all discussed earlier in this thread.
 
@WMXZ - FYI, tried to compile the mtp-logger example to a teensy 3.2 and received the following compile errors.

D:\ChuckW\Arduino\MTP_t4-master\MTP_t4-master\examples\mtp-logger\mtp-logger.ino:155:26: warning: invalid conversion from 'long unsigned int (*)()' to 'getExternalTime {aka long int (*)()}' [-fpermissive]
setSyncProvider(rtc_get);
^
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Time/time.h:2:0,
from c:\program files (x86)\arduino\hardware\tools\arm\arm-none-eabi\include\sys\stat.h:9,
from c:\program files (x86)\arduino\hardware\tools\arm\arm-none-eabi\include\sys\_default_fcntl.h:188,
from c:\program files (x86)\arduino\hardware\tools\arm\arm-none-eabi\include\sys\fcntl.h:4,
from c:\program files (x86)\arduino\hardware\tools\arm\arm-none-eabi\include\fcntl.h:1,
from c:\program files (x86)\arduino\hardware\teensy\avr\libraries\sdfat\src\common\fsapiconstants.h:30,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat\src/ExFatLib/ExFatFile.h:36,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat\src/ExFatLib/ExFatVolume.h:28,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat\src/ExFatLib/ExFatLib.h:27,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat\src/SdFat.h:33,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:27,
from D:\ChuckW\Arduino\MTP_t4-master\MTP_t4-master\examples\mtp-logger\mtp-logger.ino:18:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Time/TimeLib.h:134:9: note: initializing argument 1 of 'void setSyncProvider(getExternalTime)'
void setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider
^
D:\ChuckW\Arduino\MTP_t4-master\MTP_t4-master\examples\mtp-logger\mtp-logger.ino: In function 'int16_t acq_check(int16_t)':
D:\ChuckW\Arduino\MTP_t4-master\MTP_t4-master\examples\mtp-logger\mtp-logger.ino:944:17: error: 'acq_start' was not declared in this scope
acq_start();
^
D:\ChuckW\Arduino\MTP_t4-master\MTP_t4-master\examples\mtp-logger\mtp-logger.ino:948:16: error: 'acq_stop' was not declared in this scope
acq_stop();
^
Using library SD at version 2.0.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Using library SdFat at version 2.0.5-beta.1 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
Using library MTP_t4-master at version 1.0.0-beta.1 in folder: D:\ChuckW\Arduino\libraries\MTP_t4-master
Using library Time at version 1.6.1 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Time
Error compiling for board Teensy 3.2 / 3.1.
 
@WMXZ - FYI, tried to compile the mtp-logger example to a teensy 3.2 and received the following compile errors.
Because it is coded for T3.5/T3.6. If really required, I suggest potential users modify the code to run on T3.2. This way the user learns the concept behind the mtp-logger.
 
So got it to work as expected.

Ran for a while then all of a sudden the "loop" function slowed everything to a crawl.

I was not transferring nor doing anything with the MTP nor any specific Serial traffic as this is designed to be stand alone and only needs access when logging is finished or something needs reconfigured.

I there a way from keeping the MTP from turning this into a slug?

Any thought are appreciated.

FYI: I am running a T4.1/TD1.5.4/the latest MTP release.

Thanks

Bruce
 
So got it to work as expected.

Ran for a while then all of a sudden the "loop" function slowed everything to a crawl.

I was not transferring nor doing anything with the MTP nor any specific Serial traffic as this is designed to be stand alone and only needs access when logging is finished or something needs reconfigured.

I there a way from keeping the MTP from turning this into a slug?

Any thought are appreciated.

FYI: I am running a T4.1/TD1.5.4/the latest MTP release.

Thanks

Bruce

MTP on Teensy is a responder, if there is no PC attached, or if PC is not interrogating, there should be no activity.
Also, while you acquire data, best is not to call mtpd.loop().
 
Back
Top