From f923427dc1d83602cb52efadabf9694616ba5ed0 Mon Sep 17 00:00:00 2001 From: odaki Date: Sat, 4 Jan 2020 12:51:20 +0900 Subject: [PATCH 1/5] Show the FlashAir IP address Displays the FlashAir IP address in the "Support" menu if the card is available. If no IP address has been assigned yet, "0.0.0.0" will be displayed. --- Firmware/ultralcd.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5d0abeac9..f9260d3e5 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2192,11 +2192,14 @@ static void lcd_support_menu() // Menu was entered or SD card status has changed (plugged in or removed). // Initialize its status. _md->status = 1; - _md->is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(_md->ip); - if (_md->is_flash_air) + _md->is_flash_air = card.ToshibaFlashAir_isEnabled(); + if (_md->is_flash_air) { + card.ToshibaFlashAir_GetIP(_md->ip); // ip[4] filled with 0 if it failed + // Prepare IP string from ip[4] sprintf_P(_md->ip_str, PSTR("%d.%d.%d.%d"), _md->ip[0], _md->ip[1], _md->ip[2], _md->ip[3]); + } } else if (_md->is_flash_air && _md->ip[0] == 0 && _md->ip[1] == 0 && _md->ip[2] == 0 && _md->ip[3] == 0 && @@ -2256,7 +2259,11 @@ static void lcd_support_menu() if (_md->is_flash_air) { MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(PSTR("FlashAir IP Addr:")); //c=18 r=1 -///! MENU_ITEM(back_RAM, _md->ip_str, 0); + MENU_ITEM_BACK_P(PSTR(" ")); + if (((menu_item - 1) == menu_line) && lcd_draw_update) { + lcd_set_cursor(2, menu_row); + lcd_printf_P(PSTR("%s"), _md->ip_str); + } } #ifndef MK1BP From 2ca1bc0acb43f0ec88ee8f50f1b591380307bf99 Mon Sep 17 00:00:00 2001 From: odaki Date: Sat, 11 Jan 2020 21:47:16 +0900 Subject: [PATCH 2/5] Support W-04 firmware 4.0.0.01+ W-04 needs to use CMD17 instead of CMD48 to retrieve iSDIO register memories. To supporting both W-03 and W-04 card, I changed the readExt() code to use CMD48 first and use CMD17 if it returned some error. This method is from the FlashAir developer sample code. https://flashair-developers.github.io/website/docs/tutorials/arduino/2 --- Firmware/Sd2Card.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 449590f17..5449fccd9 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -774,7 +774,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) { uint16_t i; // send command and argument. - if (cardCommand(CMD48, arg)) { + if (cardCommand(CMD48, arg) && cardCommand(CMD17, arg)) { // CMD48 for W-03, CMD17 for W-04 error(SD_CARD_ERROR_CMD48); goto fail; } From 99545a006cc1f61f14c78d231142acb1ea3e4bdc Mon Sep 17 00:00:00 2001 From: odaki Date: Sun, 12 Jan 2020 12:45:43 +0900 Subject: [PATCH 3/5] M46 "Show the assigned IP address" activated According to the reprap wiki, M46 has been assigned to display its assigned IP address, but has been disabled. Now that Toshiba FlashAir IP address processing is working, I activate the M46 code so that I can read the IP address information via serial. --- Firmware/Marlin_main.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4970091ea..fb0f1a1bb 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5584,28 +5584,32 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) } break; - /* + //! ### M46 - Show the assigned IP address (Prusa specific) + // -------------------------------------------------------------------- case 46: { // M46: Prusa3D: Show the assigned IP address. - uint8_t ip[4]; - bool hasIP = card.ToshibaFlashAir_GetIP(ip); - if (hasIP) { - SERIAL_ECHOPGM("Toshiba FlashAir current IP: "); - SERIAL_ECHO(int(ip[0])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[1])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[2])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[3])); - SERIAL_ECHOLNPGM(""); + if (card.ToshibaFlashAir_isEnabled()) { + uint8_t ip[4]; + bool hasIP = card.ToshibaFlashAir_GetIP(ip); + if (hasIP) { + // SERIAL_PROTOCOLPGM("Toshiba FlashAir current IP: "); + SERIAL_PROTOCOL(int(ip[0])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[1])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[2])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[3])); + SERIAL_PROTOCOLPGM("\n"); + } else { + SERIAL_PROTOCOLPGM("?Toshiba FlashAir GetIP failed\n"); + } } else { - SERIAL_ECHOLNPGM("Toshiba FlashAir GetIP failed"); + SERIAL_PROTOCOLPGM("n/a\n"); } break; } - */ //! ### M47 - Show end stops dialog on the display (Prusa specific) // ---------------------------------------------------- From b09761ed712a8305ee459c6964b0ad01bf74c5fb Mon Sep 17 00:00:00 2001 From: odaki Date: Thu, 16 Jan 2020 21:38:39 +0900 Subject: [PATCH 4/5] Remove '/*' from M46 source I forgot to remove the unintended comment start mark when merge. It has been deleted. --- Firmware/Marlin_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8f232fb93..7c4a724f5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5829,8 +5829,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) /*! ### M46 - Show the assigned IP address M46: Show the assigned IP address. */ - /* - case 46: + case 46: { // M46: Prusa3D: Show the assigned IP address. if (card.ToshibaFlashAir_isEnabled()) { From 684b47e417ee75ce69f0f4e46f2f3c4e5f097468 Mon Sep 17 00:00:00 2001 From: odaki Date: Sun, 15 Mar 2020 19:04:02 +0900 Subject: [PATCH 5/5] Update reference URL There was an official website of Toshiba called "FlashAir Developers '', and there was information necessary for FlashAir development, but since it closed in September 2019. Instead, I will point an archive site for developers. --- Firmware/Sd2Card.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 5449fccd9..d1d350563 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -767,6 +767,9 @@ uint8_t Sd2Card::waitStartBlock(void) { // Toshiba FlashAir support, copied from // https://flashair-developers.com/en/documents/tutorials/arduino/ +// However, the official website was closed in September 2019. +// There is an archived website (written in Japanese). +// https://flashair-developers.github.io/website/docs/tutorials/arduino/2.html //------------------------------------------------------------------------------ /** Perform Extention Read. */