Selecting G-code files from SD with serial I'm doing a project for college connecting an app made with app inventor to a Raspberry Pi and then using the RPi to make a printing queue for a Prusa P3 Steel. 

The thing is that I already have the comm between the app and the RPi but I need to connect the RPi to the Arduino via USB and select the G-code files that are in the SD card of the Prusa to print. I don't know where should I put the function in the Marlin code or how to manage the serial port read function. 

Any ideas?
You can send the G Codes to select and print a file over the serial connection. 


List the files


  M20

Select a file name


  M23 filename.gco

Start/Resue the print


  M24



See https://reprap.org/wiki/G-code for more information M20 through M39 are the ones for interfacing with SD Card files.