Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ void sd_mmc_spi_mem_init(void) {
}

Ctrl_status sd_mmc_spi_test_unit_ready(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
return CTRL_GOOD;
}

// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
*nb_sector = card.getSd2Card().cardSize() - 1;
return CTRL_GOOD;
Expand All @@ -42,7 +42,7 @@ bool sd_mmc_spi_wr_protect(void) {
}

bool sd_mmc_spi_removal(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return true;
return false;
}
Expand All @@ -61,7 +61,7 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE];
// #define DEBUG_MMC

Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;

#ifdef DEBUG_MMC
Expand Down Expand Up @@ -95,7 +95,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
}

Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;

#ifdef DEBUG_MMC
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_LPC1768/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void HAL_idletask(void) {
// the disk if Marlin has it mounted. Unfortuately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
if (card.cardOK)
if (card.flag.cardOK)
MSC_Aquire_Lock();
else
MSC_Release_Lock();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
char eeprom_filename[] = "eeprom.dat";

bool PersistentStore::access_start() {
if (!card.cardOK) return false;
if (!card.flag.cardOK) return false;
int16_t bytes_read = 0;
constexpr char eeprom_zero = 0xFF;
card.openFile(eeprom_filename, true);
Expand All @@ -54,7 +54,7 @@ bool PersistentStore::access_start() {
}

bool PersistentStore::access_finish() {
if (!card.cardOK) return false;
if (!card.flag.cardOK) return false;
card.openFile(eeprom_filename, true);
int16_t bytes_written = card.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
card.closefile();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ void loop() {
#if ENABLED(SDSUPPORT)
card.checkautostart();

if (card.abort_sd_printing) {
if (card.flag.abort_sd_printing) {
card.stopSDPrint(
#if SD_RESORT
true
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/power_loss_recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void PrintJobRecovery::changed() {
*/
void PrintJobRecovery::check() {
if (enabled) {
if (!card.cardOK) card.initsd();
if (card.cardOK) {
if (!card.flag.cardOK) card.initsd();
if (card.flag.cardOK) {
load();
if (!valid()) return purge();
enqueue_and_echo_commands_P(PSTR("M1000 S"));
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/power_loss_recovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct {
char command_queue[BUFSIZE][MAX_CMD_SIZE];

// SD Filename and position
char sd_filename[MAXPATHNAMELENGTH];
char sd_filename[MAXPATHNAMELENGTH + 1];
uint32_t sdpos;

// Job elapsed time
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static int read_serial(const uint8_t index) {
break;
case StreamState::STREAM_COMPLETE:
stream_state = StreamState::STREAM_RESET;
card.binary_mode = false;
card.flag.binary_mode = false;
card.closefile();
CARD_ECHO_P("echo: ");
CARD_ECHO_P(card.filename);
Expand All @@ -514,7 +514,7 @@ static int read_serial(const uint8_t index) {
return;
case StreamState::STREAM_FAILED:
stream_state = StreamState::STREAM_RESET;
card.binary_mode = false;
card.flag.binary_mode = false;
card.closefile();
card.removeFile(card.filename);
CARD_ECHOLN_P("echo: File transfer failed");
Expand Down Expand Up @@ -549,7 +549,7 @@ inline void get_serial_commands() {
;

#if ENABLED(FAST_FILE_TRANSFER)
if (card.saving && card.binary_mode) {
if (card.flag.saving && card.flag.binary_mode) {
/**
* For binary stream file transfer, use serial_line_buffer as the working
* receive buffer (which limits the packet size to MAX_CMD_SIZE).
Expand Down Expand Up @@ -630,7 +630,7 @@ inline void get_serial_commands() {
gcode_LastN = gcode_N;
}
#if ENABLED(SDSUPPORT)
else if (card.saving && strcmp(command, "M29") != 0) // No line number with M29 in Pronterface
else if (card.flag.saving && strcmp(command, "M29") != 0) // No line number with M29 in Pronterface
return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i);
#endif

Expand Down Expand Up @@ -838,7 +838,7 @@ void advance_command_queue() {

#if ENABLED(SDSUPPORT)

if (card.saving) {
if (card.flag.saving) {
char* command = command_queue[cmd_queue_index_r];
if (strstr_P(command, PSTR("M29"))) {
// M29 closes the file
Expand All @@ -860,7 +860,7 @@ void advance_command_queue() {
else {
// Write the string from the read buffer to SD
card.write_command(command);
if (card.logging)
if (card.flag.logging)
gcode.process_next_command(); // The card is saving because it's logging
else
ok_to_send();
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/gcode/sdcard/M20-M30_M32-M34_M524_M928.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void GcodeSuite::M25() {
* M26: Set SD Card file index
*/
void GcodeSuite::M26() {
if (card.cardOK && parser.seenval('S'))
if (card.flag.cardOK && parser.seenval('S'))
card.setIndex(parser.value_long());
}

Expand Down Expand Up @@ -178,7 +178,7 @@ void GcodeSuite::M28() {
}

// Binary transfer mode
if ((card.binary_mode = binary_mode)) {
if ((card.flag.binary_mode = binary_mode)) {
SERIAL_ECHO_START_P(port);
SERIAL_ECHO_P(port, " preparing to receive: ");
SERIAL_ECHOLN_P(port, p);
Expand All @@ -202,14 +202,14 @@ void GcodeSuite::M28() {
* Processed in write to file routine
*/
void GcodeSuite::M29() {
// card.saving = false;
// card.flag.saving = false;
}

/**
* M30 <filename>: Delete SD Card file
*/
void GcodeSuite::M30() {
if (card.cardOK) {
if (card.flag.cardOK) {
card.closefile();
card.removeFile(parser.string_arg);
}
Expand All @@ -228,7 +228,7 @@ void GcodeSuite::M30() {
void GcodeSuite::M32() {
if (IS_SD_PRINTING()) planner.synchronize();

if (card.cardOK) {
if (card.flag.cardOK) {
const bool call_procedure = parser.boolval('P');

card.openFile(parser.string_arg, true, call_procedure);
Expand Down Expand Up @@ -286,7 +286,7 @@ void GcodeSuite::M32() {
* M524: Abort the current SD print job (started with M24)
*/
void GcodeSuite::M524() {
if (IS_SD_PRINTING()) card.abort_sd_printing = true;
if (IS_SD_PRINTING()) card.flag.abort_sd_printing = true;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/lcd/extensible_ui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,15 @@ namespace ExtUI {
}

bool isPrintingFromMedia() {
return IFSD(card.cardOK && card.isFileOpen(), false);
return IFSD(card.flag.cardOK && card.isFileOpen(), false);
}

bool isPrinting() {
return (planner.movesplanned() || IS_SD_PRINTING() || isPrintingFromMedia());
}

bool isMediaInserted() {
return IFSD(IS_SD_INSERTED() && card.cardOK, false);
return IFSD(IS_SD_INSERTED() && card.flag.cardOK, false);
}

void pausePrint() {
Expand Down Expand Up @@ -612,7 +612,7 @@ namespace ExtUI {
void stopPrint() {
#if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false;
card.abort_sd_printing = true;
card.flag.abort_sd_printing = true;
ExtUI::onStatusChanged(PSTR(MSG_PRINT_ABORTED));
#endif
}
Expand Down Expand Up @@ -648,7 +648,7 @@ namespace ExtUI {
}

bool FileList::isDir() {
return IFSD(card.filenameIsDir, false);
return IFSD(card.flag.filenameIsDir, false);
}

uint16_t FileList::count() {
Expand Down Expand Up @@ -697,13 +697,13 @@ void MarlinUI::update() {
last_sd_status = sd_status;
if (sd_status) {
card.initsd();
if (card.cardOK)
if (card.flag.cardOK)
ExtUI::onMediaInserted();
else
ExtUI::onMediaError();
}
else {
const bool ok = card.cardOK;
const bool ok = card.flag.cardOK;
card.release();
if (ok) ExtUI::onMediaRemoved();
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/malyanlcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void process_lcd_p_command(const char* command) {
// There may be a difference in how V1 and V2 LCDs handle subdirectory
// prints. Investigate more. This matches the V1 motion controller actions
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
if (card.filenameIsDir) {
if (card.flag.filenameIsDir) {
card.chdir(card.filename);
write_to_lcd_P(PSTR("{SYS:DIR}"));
}
Expand Down Expand Up @@ -330,7 +330,7 @@ void process_lcd_s_command(const char* command) {

case 'L': {
#if ENABLED(SDSUPPORT)
if (!card.cardOK) card.initsd();
if (!card.flag.cardOK) card.initsd();

// A more efficient way to do this would be to
// implement a callback in the ls_SerialPrint code, but
Expand All @@ -342,7 +342,7 @@ void process_lcd_s_command(const char* command) {
uint16_t file_count = card.get_num_Files();
for (uint16_t i = 0; i < file_count; i++) {
card.getfilename(i);
sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
sprintf_P(message_buffer, card.flag.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
write_to_lcd(message_buffer);
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

void lcd_sdcard_stop() {
wait_for_heatup = wait_for_user = false;
card.abort_sd_printing = true;
card.flag.abort_sd_printing = true;
ui.setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
ui.return_to_status();
}
Expand Down Expand Up @@ -86,7 +86,7 @@ void menu_main() {
MENU_BACK(MSG_WATCH);

#if ENABLED(SDSUPPORT)
if (card.cardOK) {
if (card.flag.cardOK) {
if (card.isFileOpen()) {
if (IS_SD_PRINTING())
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void menu_sdcard() {

card.getfilename_sorted(nr);

if (card.filenameIsDir)
if (card.flag.filenameIsDir)
MENU_ITEM(sdfolder, MSG_CARD_MENU, card);
else
MENU_ITEM(sdfile, MSG_CARD_MENU, card);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/sd/SdFatConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
* Defines for 8.3 and long (vfat) filenames
*/

#define FILENAME_LENGTH 13 // Number of UTF-16 characters per entry
#define FILENAME_LENGTH 12 // Number of UTF-16 characters per entry

// Total bytes needed to store a single long filename
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH * MAX_VFAT_ENTRIES + 1)
#define LONG_FILENAME_LENGTH ((FILENAME_LENGTH) * (MAX_VFAT_ENTRIES))
Loading