diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index ac4d894..a2554c3 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -11,57 +11,121 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup msbuild - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 - name: Build run: msbuild /p:PlatformToolset=v142 /p:Configuration=Release - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: PMAP.exe + name: PMAP-wincli path: Release/PMAP.exe - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: PMAP-win.exe + name: PMAP-wingui path: Release/PMAP-win.exe - - name: Create release + build-macos: + name: PMAP macos compilation + runs-on: macos-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build + run: | + cd PMAP-unix + make + tar -zcvf PMAP-macos.tar.gz pmap + + - name: Build id + run: | + cd PMAP-unix + make clean + make ID_MANAGEMENT=1 + tar -zcvf PMAP-macos-id.tar.gz pmap + + - uses: actions/upload-artifact@v4 + with: + name: PMAP-macos + path: PMAP-unix/PMAP-macos.tar.gz + + - uses: actions/upload-artifact@v4 + with: + name: PMAP-macos-id + path: PMAP-unix/PMAP-macos-id.tar.gz + + build-linux: + name: PMAP linux compilation + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build + run: | + cd PMAP-unix + make + tar -zcvf PMAP-linux.tar.gz pmap + + - name: Build id + run: | + cd PMAP-unix + make clean + make ID_MANAGEMENT=1 + tar -zcvf PMAP-linux-id.tar.gz pmap + + - uses: actions/upload-artifact@v4 + with: + name: PMAP-linux + path: PMAP-unix/PMAP-linux.tar.gz + + - uses: actions/upload-artifact@v4 + with: + name: PMAP-linux-id + path: PMAP-unix/PMAP-linux-id.tar.gz + + create-release: + name: Create release + runs-on: ubuntu-latest + needs: [build-win, build-macos, build-linux] + steps: + - uses: actions/download-artifact@v4 + - name: Display structure of downloaded files + run: ls -R + + - name: Create release for master/main if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "latest" title: "Latest development build" - files: Release/PMAP.exe + files: | + ./PMAP-wincli/PMAP.exe + ./PMAP-wingui/PMAP-win.exe + ./PMAP-macos/PMAP-macos.tar.gz + ./PMAP-macos-id/PMAP-macos-id.tar.gz + ./PMAP-linux/PMAP-linux.tar.gz + ./PMAP-linux-id/PMAP-linux-id.tar.gz - - name: Create release + - name: Create release for tagged versions if: startsWith(github.ref, 'refs/tags/v') uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: "${{ contains(github.ref, '-rc') }}" title: PMAP-${{ github.ref }} - files: Release/PMAP.exe - - # build-linux: - # name: PMAP linux compilation - # runs-on: ubuntu-latest - - # steps: - # - name: Checkout Repository - # uses: actions/checkout@v3 - - # - name: Build - # run: | - # cd PMAP-linux - # make - # tar -zcvf pmap.tar.gz pmap - - # - uses: actions/upload-artifact@v3 - # with: - # name: PMAP - # path: linux/pmap.tar.gz + files: | + ./release/win/PMAP.exe + ./release/win/PMAP-win.exe + ./release/macos/PMAP-macos.tar.gz + ./release/macos/PMAP-macos-id.tar.gz + ./release/linux/PMAP-linux.tar.gz + ./release/linux/PMAP-linux-id.tar.gz diff --git a/.gitignore b/.gitignore index 54b2550..fc71d71 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ .vs Debug Release +PMAP-unix/pmap +PMAP-linux/pmap !.github !.editorconfig diff --git a/PMAP-linux/Makefile b/PMAP-linux/Makefile deleted file mode 100644 index 2b4df9f..0000000 --- a/PMAP-linux/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -VPATH = ./:../base/ - -ELF = pmap -CFLAGS = -O2 -I. -OBJS += eeprom-main.o eeprom.o elect.o elect-main.o mecha-main.o mecha.o updates.o platform-linux.o -OBJS += ../PMAP/main.o -# OBJS += eeprom-id.o id-main.o - -$(ELF): $(OBJS) - $(CC) -o $(ELF) $(OBJS) - -clean: - rm -f $(ELF) $(OBJS) diff --git a/PMAP-linux/platform-linux.c b/PMAP-linux/platform-linux.c deleted file mode 100644 index b9a0bd7..0000000 --- a/PMAP-linux/platform-linux.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform.h" -#include "../base/mecha.h" - -static int ComPortFD = -1; -// static unsigned short RxTimeout; -static struct termios OldTio; - -int PlatOpenCOMPort(const char *device) -{ - struct termios tio; - int result; - - if (ComPortFD < 0) - { - if ((ComPortFD = open(device, O_RDWR | O_NOCTTY)) >= 0) - { - tcgetattr(ComPortFD, &OldTio); - memset(&tio, 0, sizeof(tio)); - - tio.c_cflag = B57600 | CS8 | CLOCAL | CREAD; - tio.c_lflag = ICANON; - - tcflush(ComPortFD, TCIFLUSH); - tcsetattr(ComPortFD, TCSANOW, &tio); - result = 0; - } - else - result = ComPortFD; - } - else - result = EMFILE; - - return result; -} - -int PlatReadCOMPort(char *data, int n, unsigned short timeout) -{ - struct timeval SelTimeout; - fd_set RdSet; - - FD_ZERO(&RdSet); - FD_SET(ComPortFD, &RdSet); - SelTimeout.tv_sec = 0; - SelTimeout.tv_usec = timeout * 1000; - if (select(ComPortFD + 1, &RdSet, NULL, NULL, &SelTimeout) == 1) - return read(ComPortFD, data, n); - else - return -1; -} - -int PlatWriteCOMPort(const char *data) -{ - return write(ComPortFD, data, strlen(data)); -} - -void PlatCloseCOMPort(void) -{ - tcsetattr(ComPortFD, TCSANOW, &OldTio); - close(ComPortFD); - ComPortFD = -1; -} - -void PlatSleep(unsigned short int msec) -{ - usleep((unsigned int)msec * 1000); -} - -void PlatShowEMessage(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - va_end(args); -} - -void PlatShowMessageB(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - - // Block until the user presses ENTER - while (getchar() != '\n') - { - }; - - va_end(args); -} - - -int pstricmp(const char *s1, const char *s2) -{ - char s1char, s2char; - - for (s1char = *s1, s2char = *s2; *s1 != '\0' && *s2 != '\0'; s1++, s2++, s1char = *s1, s2char = *s2) - { - if (isalpha(s1char)) - s1char = toupper(s1char); - if (isalpha(s2char)) - s2char = toupper(s2char); - if (s1char != s2char) - break; - } - - return (s1char - s2char); -} - -int pstrincmp(const char *s1, const char *s2, int len) -{ - char s1char, s2char; - - for (s1char = *s1, s2char = *s2; *s1 != '\0' && *s2 != '\0' && len > 0; s1++, s2++, s1char = *s1, s2char = *s2, len--) - { - if (isalpha(s1char)) - s1char = toupper(s1char); - if (isalpha(s2char)) - s2char = toupper(s2char); - if (s1char != s2char) - break; - } - - return ((len == 0) ? 0 : s1char - s2char); -} diff --git a/PMAP-linux/platform.h b/PMAP-linux/platform.h deleted file mode 100644 index ea1b00c..0000000 --- a/PMAP-linux/platform.h +++ /dev/null @@ -1,19 +0,0 @@ -typedef unsigned char u8; -typedef unsigned short int u16; -typedef unsigned int u32; - -int PlatOpenCOMPort(const char *device); -int PlatReadCOMPort(char *data, int n, unsigned short timeout); -int PlatWriteCOMPort(const char *data); -void PlatCloseCOMPort(void); -void PlatSleep(unsigned short int msec); -void PlatShowEMessage(const char *format, ...); -// Block until the user acknowledges. -// void PlatShowMessage(const char *format, ...); -#define PlatShowMessage PlatShowEMessage -#define PlatDPrintf PlatShowEMessage -void PlatShowMessageB(const char *format, ...); - -// If necessary, provide these functions, otherwise define them to their equivalents -int pstricmp(const char *s1, const char *s2); -int pstrincmp(const char *s1, const char *s2, int len); diff --git a/PMAP-unix/Makefile b/PMAP-unix/Makefile new file mode 100644 index 0000000..777390a --- /dev/null +++ b/PMAP-unix/Makefile @@ -0,0 +1,18 @@ +VPATH = ./:../base/ + +ELF = pmap +CFLAGS ?= -O2 +CPPFLAGS = -I. +OBJS += eeprom-main.o eeprom.o elect.o elect-main.o mecha-main.o mecha.o updates.o platform-unix.o +OBJS += main.o +# Add -DID_MANAGEMENT when ID_MANAGEMENT is defined +ifdef ID_MANAGEMENT +CPPFLAGS += -DID_MANAGEMENT +OBJS += eeprom-id.o id-main.o +endif + +$(ELF): $(OBJS) + $(CC) -o $(ELF) $(OBJS) + +clean: + rm -f $(ELF) $(OBJS) eeprom-id.o id-main.o diff --git a/PMAP-unix/platform-unix.c b/PMAP-unix/platform-unix.c new file mode 100644 index 0000000..c5a0028 --- /dev/null +++ b/PMAP-unix/platform-unix.c @@ -0,0 +1,298 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../base/platform.h" +#include "../base/mecha.h" + +static int ComPortHandle = -1; +static unsigned short RxTimeout; +static FILE *DebugOutputFile = NULL; + +int PlatOpenCOMPort(const char *device) +{ + struct termios options; + int result; + + if (ComPortHandle == -1) + { + // List available serial devices + PlatShowMessage("Available serial devices in /dev/:\n"); + DIR *dir; + const struct dirent *entry; + + dir = opendir("/dev"); + if (dir != NULL) + { + while ((entry = readdir(dir))) + { + if (strncmp(entry->d_name, "cu.", 3) == 0) + { + PlatShowMessage("/dev/%s\n", entry->d_name); + } + } + closedir(dir); + } + + PlatShowMessage("Opening COM port: %s\n", device); + + ComPortHandle = open(device, O_RDWR | O_NOCTTY | O_NDELAY); + + if (ComPortHandle != -1) + { + PlatShowMessage("COM port opened successfully.\n"); + + fcntl(ComPortHandle, F_SETFL, 0); + if (tcgetattr(ComPortHandle, &options) == -1) + { + PlatShowMessage("Failed to get terminal attributes. Error code: %d\n", errno); + close(ComPortHandle); + ComPortHandle = -1; + return errno; + } + + cfsetispeed(&options, B57600); + cfsetospeed(&options, B57600); + options.c_cflag &= ~PARENB; // No parity + options.c_cflag &= ~CSTOPB; // 1 stop bit + options.c_cflag &= ~CSIZE; + options.c_cflag |= CS8; // 8 data bits + options.c_cflag &= ~CRTSCTS; // No hardware flow control + options.c_iflag &= ~(IXON | IXOFF | IXANY); // No software flow control + options.c_lflag = 0; + options.c_oflag = 0; + + if (tcsetattr(ComPortHandle, TCSANOW, &options) == -1) + { + PlatShowMessage("Failed to set terminal attributes. Error code: %d\n", errno); + close(ComPortHandle); + ComPortHandle = -1; + return errno; + } + + if (tcflush(ComPortHandle, TCIOFLUSH) == -1) + { + PlatShowMessage("Failed to flush terminal I/O. Error code: %d\n", errno); + close(ComPortHandle); + ComPortHandle = -1; + return errno; + } + + RxTimeout = MECHA_TASK_NORMAL_TO; + + PlatShowMessage("COM port configuration set.\n"); + result = 0; + } + else + { + result = errno; + PlatShowMessage("Failed to open COM port. Error code: %d\n", result); + } + } + else + { + PlatShowMessage("COM port is already open.\n"); + result = EMFILE; + } + + return result; +} + +int PlatReadCOMPort(char *data, int n, unsigned short timeout) +{ + int result; + + if (ComPortHandle == -1) + { + PlatShowMessage("COM port is not open.\n"); + return -1; // Return an error code indicating that the COM port is not open. + } + + fd_set readfds; + struct timeval tv; + + FD_ZERO(&readfds); + FD_SET(ComPortHandle, &readfds); + + tv.tv_sec = timeout / 1000; + tv.tv_usec = (timeout % 1000) * 1000; + + result = select(ComPortHandle + 1, &readfds, NULL, NULL, &tv); + + if (result > 0) + { + // Data is available, read it + result = read(ComPortHandle, data, n); + + if (result < 0) + { + PlatShowMessage("Read from COM port failed.\n"); + } + } + else if (result == 0) + { + // Timeout + PlatShowMessage("Read from COM port timed out.\n"); + } + else + { + // Error + PlatShowMessage("Select function error.\n"); + } + + return result; +} + +int PlatWriteCOMPort(const char *data) +{ + int result = write(ComPortHandle, data, strlen(data)); + tcdrain(ComPortHandle); + + if (result < 0) + { + PlatShowMessage("Write to COM port failed.\n"); + } + + return result; +} + +void PlatCloseCOMPort(void) +{ + if (ComPortHandle != -1) + { + PlatShowMessage("Closing COM port...\n"); + close(ComPortHandle); + ComPortHandle = -1; + PlatShowMessage("COM port closed.\n"); + } + else + { + PlatShowMessage("COM port is already closed.\n"); + } +} + +void PlatSleep(unsigned short int msec) +{ + usleep((useconds_t)msec * 1000); +} + +void PlatShowEMessage(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + if (DebugOutputFile != NULL) + vfprintf(DebugOutputFile, format, args); + va_end(args); +} + +void PlatShowMessage(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + if (DebugOutputFile != NULL) + vfprintf(DebugOutputFile, format, args); + va_end(args); +} + +void PlatShowMessageB(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + if (DebugOutputFile != NULL) + vfprintf(DebugOutputFile, format, args); + + // Block until the user presses ENTER + while (getchar() != '\n') + { + }; + + va_end(args); +} + +void PlatDebugInit(void) +{ + // Get the current time + time_t rawtime; + struct tm *timeinfo; + char timestamp[20]; // Adjust the size according to your needs + + time(&rawtime); + timeinfo = localtime(&rawtime); + + // Format the timestamp (e.g., "2023-10-14_12-34-56") + strftime(timestamp, sizeof(timestamp), "%Y-%m-%d_%H-%M-%S", timeinfo); + + // Create the filename with timestamp + char filename[256]; // Adjust the size according to your needs + snprintf(filename, sizeof(filename), "pmap_%s.log", timestamp); + + DebugOutputFile = fopen(filename, "w"); +} + +void PlatDebugDeinit(void) +{ + if (DebugOutputFile != NULL) + { + fclose(DebugOutputFile); + DebugOutputFile = NULL; + } +} + +void PlatDPrintf(const char *format, ...) +{ + va_list args; + + va_start(args, format); + if (DebugOutputFile != NULL) + vfprintf(DebugOutputFile, format, args); + va_end(args); +} + +int pstricmp(const char *s1, const char *s2) +{ + char s1char, s2char; + + for (s1char = *s1, s2char = *s2; *s1 != '\0' && *s2 != '\0'; s1++, s2++, s1char = *s1, s2char = *s2) + { + if (isalpha(s1char)) + s1char = toupper(s1char); + if (isalpha(s2char)) + s2char = toupper(s2char); + if (s1char != s2char) + break; + } + + return (s1char - s2char); +} + +int pstrincmp(const char *s1, const char *s2, int len) +{ + char s1char, s2char; + + for (s1char = *s1, s2char = *s2; *s1 != '\0' && *s2 != '\0' && len > 0; s1++, s2++, s1char = *s1, s2char = *s2, len--) + { + if (isalpha(s1char)) + s1char = toupper(s1char); + if (isalpha(s2char)) + s2char = toupper(s2char); + if (s1char != s2char) + break; + } + + return ((len == 0) ? 0 : s1char - s2char); +} diff --git a/PMAP-win/platform.h b/PMAP-win/platform.h deleted file mode 100644 index e20e254..0000000 --- a/PMAP-win/platform.h +++ /dev/null @@ -1,21 +0,0 @@ -typedef unsigned char u8; -typedef unsigned short int u16; -typedef unsigned int u32; - -int PlatOpenCOMPort(const char *device); -int PlatReadCOMPort(char *data, int n, unsigned short timeout); -int PlatWriteCOMPort(const char *data); -void PlatCloseCOMPort(void); -void PlatSleep(unsigned short int msec); -void PlatShowEMessage(const char *format, ...); -void PlatShowMessage(const char *format, ...); -// void PlatShowMessageB(const char *format, ...); -#define PlatShowMessageB PlatShowMessage - -void PlatDebugInit(void); -void PlatDebugDeinit(void); -void PlatDPrintf(const char *format, ...); - -// If necessary, provide these functions, otherwise define them to their equivalents -int pstricmp(const char *s1, const char *s2); -int pstrincmp(const char *s1, const char *s2, int len); diff --git a/PMAP/PMAP.vcxproj b/PMAP-wincli/PMAP.vcxproj similarity index 86% rename from PMAP/PMAP.vcxproj rename to PMAP-wincli/PMAP.vcxproj index 325397e..8cba406 100644 --- a/PMAP/PMAP.vcxproj +++ b/PMAP-wincli/PMAP.vcxproj @@ -51,7 +51,7 @@ Level3 Disabled - WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ID_MANAGEMENT=1;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\base;.; @@ -67,7 +67,7 @@ MaxSpeed true true - WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ID_MANAGEMENT=1;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\base;.; @@ -78,23 +78,28 @@ - - - - - + + + + + + + + + - - + + + diff --git a/PMAP/platform.c b/PMAP-wincli/platform-win.c similarity index 74% rename from PMAP/platform.c rename to PMAP-wincli/platform-win.c index cb8e56b..6d3b334 100644 --- a/PMAP/platform.c +++ b/PMAP-wincli/platform-win.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "platform.h" #include "mecha.h" @@ -11,8 +13,27 @@ static HANDLE ComPortHandle = INVALID_HANDLE_VALUE; static unsigned short RxTimeout; static FILE *DebugOutputFile = NULL; +void ListSerialDevices() +{ + char targetPath[256]; + char dosDeviceName[256]; + char comPortName[] = "COM"; + + for (int portNum = 1; portNum <= 256; portNum++) + { + snprintf(dosDeviceName, sizeof(dosDeviceName), "%s%d", comPortName, portNum); + + if (QueryDosDevice(dosDeviceName, targetPath, sizeof(targetPath)) != 0) + { + PlatShowMessage("Found COM Port: %s\n", dosDeviceName); + PlatShowMessage("Target Path: %s\n", targetPath); + } + } +} + int PlatOpenCOMPort(const char *device) { + ListSerialDevices(); COMMTIMEOUTS CommTimeout; DCB DeviceControlBlock; int result; @@ -44,6 +65,9 @@ int PlatOpenCOMPort(const char *device) else result = EMFILE; + if (result != 0) + PlatCloseCOMPort(); + return result; } @@ -80,13 +104,27 @@ int PlatWriteCOMPort(const char *data) else result = -EIO; + if (result < 0) + { + PlatShowMessage("Write to COM port failed.\n"); + } + return result; } void PlatCloseCOMPort(void) { - CloseHandle(ComPortHandle); - ComPortHandle = INVALID_HANDLE_VALUE; + if (ComPortHandle != INVALID_HANDLE_VALUE) + { + PlatShowMessage("Closing COM port...\n"); + CloseHandle(ComPortHandle); + ComPortHandle = INVALID_HANDLE_VALUE; + PlatShowMessage("COM port closed.\n"); + } + else + { + PlatShowMessage("COM port is already closed.\n"); + } } void PlatSleep(unsigned short int msec) @@ -135,7 +173,22 @@ void PlatShowMessageB(const char *format, ...) void PlatDebugInit(void) { - DebugOutputFile = fopen("pmap.log", "w"); + // Get the current time + time_t rawtime; + struct tm *timeinfo; + char timestamp[20]; // Adjust the size according to your needs + + time(&rawtime); + timeinfo = localtime(&rawtime); + + // Format the timestamp (e.g., "2023-10-14_12-34-56") + strftime(timestamp, sizeof(timestamp), "%Y-%m-%d_%H-%M-%S", timeinfo); + + // Create the filename with timestamp + char filename[256]; // Adjust the size according to your needs + snprintf(filename, sizeof(filename), "pmap_%s.log", timestamp); + + DebugOutputFile = fopen(filename, "w"); } void PlatDebugDeinit(void) diff --git a/PMAP-win/PMAP-win.vcxproj b/PMAP-wingui/PMAP-win.vcxproj similarity index 89% rename from PMAP-win/PMAP-win.vcxproj rename to PMAP-wingui/PMAP-win.vcxproj index 7f1a7f7..0b5be25 100644 --- a/PMAP-win/PMAP-win.vcxproj +++ b/PMAP-wingui/PMAP-win.vcxproj @@ -51,7 +51,7 @@ Level3 Disabled - WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + ID_MANAGEMENT=1;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) ..\base;.; @@ -67,7 +67,7 @@ MaxSpeed true true - WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + ID_MANAGEMENT=1;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) ..\base;.; @@ -82,19 +82,22 @@ + - + + + - - + + diff --git a/PMAP-win/dialogs.rc b/PMAP-wingui/dialogs.rc similarity index 81% rename from PMAP-win/dialogs.rc rename to PMAP-wingui/dialogs.rc index 1772049..88d5fd4 100644 --- a/PMAP-win/dialogs.rc +++ b/PMAP-wingui/dialogs.rc @@ -58,42 +58,42 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "PMAP" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Connect",IDC_BUTTON_CONNECT,312,27,50,14 - PUSHBUTTON "Disconnect",IDC_BUTTON_DISCONNECT,312,44,50,14,WS_DISABLED - COMBOBOX IDC_COMBO_PORT,259,28,48,98,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Port",IDC_STATIC_CONN,249,16,120,48 - GROUPBOX "Console Information",IDC_STATIC_INFO,22,16,238,99 - PUSHBUTTON "Mechanism Adjustment",IDC_BUTTON_MECHA_ADJ,172,119,68,32,BS_MULTILINE | WS_DISABLED + GROUPBOX "Console Information",IDC_STATIC_INFO,22,16,218,99 + LTEXT "MECHACON:",IDC_STATIC_LBL_MECHACON,31,30,42,8 + LTEXT "Unknown",IDC_STATIC_MECHACON,80,30,100,8 + LTEXT "Model name:",IDC_STATIC_LBL_MODEL_NAME,31,42,42,8 + LTEXT "Unknown",IDC_STATIC_MODEL_NAME,80,42,55,8 + LTEXT "MD Version:",IDC_STATIC_LBL_MD_VER,31,54,42,8 + LTEXT "Unknown",IDC_STATIC_MD_VER,80,54,55,8 + LTEXT "OP type:",IDC_STATIC_LBL_OP_TYPE,31,66,42,8 + LTEXT "Unknown",IDC_STATIC_OP_TYPE,80,66,55,8 + LTEXT "Lens type:",IDC_STATIC_LBL_LENS_TYPE,31,78,42,8 + LTEXT "Unknown",IDC_STATIC_LENS_TYPE,80,78,55,8 + LTEXT "RTC type:",IDC_STATIC_LBL_RTC_TYPE,31,90,42,8 + LTEXT "Unknown",IDC_STATIC_RTC_TYPE,80,90,55,8 + // LTEXT "Unknown",IDC_STATIC_CEXDEX,200,32,37,8 + PUSHBUTTON "ID Management",IDC_BUTTON_ID_MAN,150,37,80,14,WS_DISABLED + LTEXT "Serial:",IDC_STATIC_LBL_SERIAL,150,54,37,8 + LTEXT "Unknown",IDC_STATIC_SERIAL,195,54,30,8 + LTEXT "MODEL ID:",IDC_STATIC_LBL_MODELID,150,66,37,8 + LTEXT "Unknown",IDC_STATIC_MODEL_ID,195,66,30,8 + LTEXT "EMCS ID:",IDC_STATIC_LBL_EMCS_ID,150,78,37,8 + LTEXT "Unknown",IDC_STATIC_EMCS_ID,195,78,30,8 + LTEXT "TV System:",IDC_STATIC_LBL_TV_SYS,150,90,37,8 + LTEXT "Unknown",IDC_STATIC_TV_SYS,195,90,30,8 PUSHBUTTON "EEPROM Management",IDC_BUTTON_EEP_MAN,28,119,68,32,BS_MULTILINE | WS_DISABLED PUSHBUTTON "Electrical Adjustment",IDC_BUTTON_ELECT_ADJ,100,119,68,32,BS_MULTILINE | WS_DISABLED + PUSHBUTTON "Mechanism Adjustment",IDC_BUTTON_MECHA_ADJ,172,119,68,32,BS_MULTILINE | WS_DISABLED + PUSHBUTTON "Show MECHA Version",IDC_BUTTON_SHOW_VER,28,154,102,14,WS_DISABLED LTEXT "PMAP",IDC_STATIC_VERSION,135,157,102,8 - LTEXT "Model name:",IDC_STATIC_LBL_MODEL_NAME,31,30,42,8 - LTEXT "Unknown",IDC_STATIC_MODEL_NAME,85,31,30,8 - LTEXT "Serial:",IDC_STATIC_LBL_SERIAL,142,58,21,8 - LTEXT "Unknown",IDC_STATIC_SERIAL,192,58,30,8 - LTEXT "OP type:",IDC_STATIC_LBL_OP_TYPE,31,67,30,8 - LTEXT "Unknown",IDC_STATIC_OP_TYPE,85,67,30,8 - LTEXT "Lens type:",IDC_STATIC_LBL_LENS_TYPE,31,80,35,8 - LTEXT "Unknown",IDC_STATIC_LENS_TYPE,85,80,30,8 - LTEXT "EMCS ID:",IDC_STATIC_LBL_EMCS_ID,142,81,31,8 - LTEXT "Unknown",IDC_STATIC_EMCS_ID,192,81,30,8 - LTEXT "MECHACON:",IDC_STATIC_LBL_MECHACON,31,42,42,8 - LTEXT "Unknown",IDC_STATIC_MECHACON,85,42,30,8 - LTEXT "RTC type:",IDC_STATIC_LBL_RTC_TYPE,31,94,34,8 - LTEXT "Unknown",IDC_STATIC_RTC_TYPE,85,94,30,8 - PUSHBUTTON "ID Management",IDC_BUTTON_ID_MAN,139,41,80,14,WS_DISABLED - LTEXT "MD Version:",IDC_STATIC_LBL_MD_VER,31,54,39,8 - LTEXT "Unknown",IDC_STATIC_MD_VER,85,54,30,8 - PUSHBUTTON "Show MECHA Version",IDC_BUTTON_SHOW_VER,29,154,102,14,WS_DISABLED - LTEXT "TV System:",IDC_STATIC_LBL_TV_SYS,142,94,37,8 - LTEXT "Unknown",IDC_STATIC_TV_SYS,192,94,30,8 + GROUPBOX "Port",IDC_STATIC_CONN,249,16,120,48 + COMBOBOX IDC_COMBO_PORT,259,28,48,98,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "Connect",IDC_BUTTON_CONNECT,312,27,50,14 + PUSHBUTTON "Disconnect",IDC_BUTTON_DISCONNECT,312,44,50,14,WS_DISABLED GROUPBOX "Status",IDC_STATIC_STATUS,249,67,121,101 CONTROL "Checksum Error",IDC_CHECK_CHKSUM_ERR,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,258,78,66,10 CONTROL "RTC Battery Low",IDC_CHECK_RTC_LOW_BATT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,258,89,70,10 CONTROL "RTC No Battery",IDC_CHECK_RTC_NO_BATT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,258,101,66,10 - LTEXT "MODEL ID:",IDC_STATIC_LBL_MODELID,142,70,36,8 - LTEXT "Unknown",IDC_STATIC_MODEL_ID,192,70,30,8 - LTEXT "Unknown",IDC_STATIC_CEXDEX,141,32,30,8 END IDD_DIALOG_EEP_MAN DIALOGEX 0, 0, 434, 183 @@ -101,47 +101,47 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "EEPROM management" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - PUSHBUTTON "Cancel",IDCANCEL,377,162,50,14 - PUSHBUTTON "DVD-ROM Disc Detect",IDC_BTN_DEFAULT_DISC_DET,18,105,91,14 - PUSHBUTTON "EEGS",IDC_BTN_DEFAULT_EEGS,129,26,72,14 - PUSHBUTTON "OSD (User Data)",IDC_BTN_DEFAULT_OSD,129,41,72,14 - PUSHBUTTON "DVD Video Player",IDC_BTN_DEFAULT_DVDPL,129,103,72,14 - PUSHBUTTON "PS2 ID",IDC_BTN_DEFAULT_PS2ID,129,71,72,14 + GROUPBOX "EEPROM Management",IDC_STATIC,14,15,101,75 PUSHBUTTON "Erase EEPROM",IDC_BTN_ERASE_EEPROM,18,25,91,14 - PUSHBUTTON "DVD-ROM Tilt Motor",IDC_BTN_DEFAULT_TILT_MOTOR,18,137,91,14 - PUSHBUTTON "DVD-ROM Tray",IDC_BTN_DEFAULT_TRAY,18,153,91,14 - GROUPBOX "DVD-ROM Defaults",IDC_STC_DVDROM_DEFAULTS,14,93,98,81 - PUSHBUTTON "Clock (RTC)",IDC_BTN_DEFAULT_CLOCK,129,87,72,14 - PUSHBUTTON "Model Name",IDC_BTN_DEFAULT_MNAME,129,56,72,14 - GROUPBOX "Configuration Defaults",IDC_STATIC,117,15,101,107 - PUSHBUTTON "DVD-ROM Servo",IDC_BTN_DEFAULT_SERVO,18,121,91,14 - PUSHBUTTON "Load MECHACON Defaults",IDC_BTN_MECHA_DEFAULTS,17,40,92,14,BS_MULTILINE - GROUPBOX "EEPROM Management",IDC_STATIC,14,15,97,74 + PUSHBUTTON "Load MECHACON Defaults",IDC_BTN_MECHA_DEFAULTS,18,40,91,14,BS_MULTILINE PUSHBUTTON "Save EEPROM",IDC_BTN_SAVE_EEPROM,18,55,91,14 PUSHBUTTON "Restore EEPROM",IDC_BTN_RESTORE_EEPROM,18,70,91,14 - CONTROL "Disc Detect Area",IDC_CHK_UPD_DISC_DET,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,55,69,10 - CONTROL "EEP-ROM (ECR)",IDC_CHK_UPD_EEP_ECR,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,44,67,10 - CONTROL "Servo Area",IDC_CHK_UPD_SERVO,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,67,52,10 - CONTROL "Tilt Motor Area",IDC_CHK_UPD_TILT_MOTOR,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,78,63,10 - CONTROL "Battery/OSC Removed",IDC_CHK_EEP_STAT_NO_BATT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,231,24,67,20 - CONTROL "Battery Low Voltage",IDC_CHK_EEP_STAT_LOW_BATT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,42,64,20 - CONTROL "RTC-ECR Erased",IDC_CHK_EEP_STAT_RTC_ECR_ERASED,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,60,64,20 + GROUPBOX "DVD-ROM Defaults",IDC_STC_DVDROM_DEFAULTS,14,93,101,75 + PUSHBUTTON "DVD-ROM Disc Detect",IDC_BTN_DEFAULT_DISC_DET,18,105,91,14 + PUSHBUTTON "DVD-ROM Servo",IDC_BTN_DEFAULT_SERVO,18,120,91,14 + PUSHBUTTON "DVD-ROM Tilt Motor",IDC_BTN_DEFAULT_TILT_MOTOR,18,135,91,14 + PUSHBUTTON "DVD-ROM Tray",IDC_BTN_DEFAULT_TRAY,18,150,91,14 + GROUPBOX "Configuration Defaults",IDC_STATIC,117,15,101,105 + PUSHBUTTON "EEGS",IDC_BTN_DEFAULT_EEGS,129,25,72,14 + PUSHBUTTON "OSD (User Data)",IDC_BTN_DEFAULT_OSD,129,40,72,14 + PUSHBUTTON "Model Name",IDC_BTN_DEFAULT_MNAME,129,55,72,14 + PUSHBUTTON "PS2 ID",IDC_BTN_DEFAULT_PS2ID,129,70,72,14 + PUSHBUTTON "Clock (RTC)",IDC_BTN_DEFAULT_CLOCK,129,85,72,14 + PUSHBUTTON "DVD Video Player",IDC_BTN_DEFAULT_DVDPL,129,100,72,14 + LTEXT "Chassis:",IDC_STC_LBL_CHASSIS,127,139,28,8 + COMBOBOX IDC_CMB_CHASSIS,158,137,139,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "START",IDC_BTN_START,158,153,50,14 + CONTROL "Replaced MechaCon",IDC_CB_REPLACED_MECHACON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,155,81,10 + GROUPBOX "Status",IDC_STC_STATUS,225,15,78,88 + CONTROL "Battery/OSC Removed",IDC_CHK_EEP_STAT_NO_BATT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,24,65,20 + CONTROL "Battery Low Voltage",IDC_CHK_EEP_STAT_LOW_BATT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,42,65,20 + CONTROL "RTC-ECR Erased",IDC_CHK_EEP_STAT_RTC_ECR_ERASED,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,60,65,20 CONTROL "EEP-ROM Checksum Error",IDC_CHK_EEP_STAT_RTC_ECR_ERASED2, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,232,78,65,20 - GROUPBOX "Status",IDC_STC_STATUS,225,15,78,88 + GROUPBOX "Update Actions",IDC_STC_UPDATE_ACTIONS,309,15,112,145 CONTROL "EEPROM Update Available",IDC_CHK_EEPROM_UPD_AVAILABLE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,316,25,86,18 - CONTROL "Tray Area",IDC_CHK_UPD_TRAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,89,48,10 - CONTROL "EEGS Area",IDC_CHK_UPD_TRAY2,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,100,50,10 + CONTROL "EEP-ROM (ECR)",IDC_CHK_UPD_EEP_ECR,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,44,69,10 + CONTROL "Disc Detect Area",IDC_CHK_UPD_DISC_DET,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,55,69,10 + CONTROL "Servo Area",IDC_CHK_UPD_SERVO,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,66,69,10 + CONTROL "Tilt Motor Area",IDC_CHK_UPD_TILT_MOTOR,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,77,69,10 + CONTROL "Tray Area",IDC_CHK_UPD_TRAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,88,69,10 + CONTROL "EEGS Area",IDC_CHK_UPD_TRAY2,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,328,99,69,10 CONTROL "Load MECHACON Defaults",IDC_CHK_MECHACON_DEFAULTS, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,316,110,86,17 - GROUPBOX "Update Actions",IDC_STC_UPDATE_ACTIONS,309,15,112,145 + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,316,110,86,18 PUSHBUTTON "Update",IDC_BTN_UPDATE,316,134,50,14 - LTEXT "Chassis:",IDC_STC_LBL_CHASSIS,127,139,28,8 - COMBOBOX IDC_CMB_CHASSIS,158,137,139,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "START",IDC_BTN_START,158,153,50,14 CONTROL "Clear OSD2 Init Bit",IDC_CLR_OSD2_INIT_BIT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,370,132,50,18 - CONTROL "Replaced MechaCon",IDC_CB_REPLACED_MECHACON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,155,81,10 + PUSHBUTTON "Cancel",IDCANCEL,377,162,50,14 END IDD_DIALOG_ELECT_ADJ DIALOGEX 0, 0, 316, 89 @@ -235,49 +235,49 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "ID Management" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Close",IDOK,230,147,50,14 - PUSHBUTTON "Write ID",IDC_BUTTON_CON_ID_WR,223,24,57,13 - GROUPBOX "Console ID",IDC_STATIC_CON_ID,24,15,266,29 - PUSHBUTTON "Write ID",IDC_BUTTON_ILINK_ID_WR,224,57,57,13 - GROUPBOX "i.Link ID",IDC_STATIC_ILINK_ID,24,47,265,32 - EDITTEXT IDC_EDIT_CON_ID_0,33,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_1,57,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_2,80,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_3,103,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_4,126,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_5,148,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + GROUPBOX "Console ID",IDC_STATIC_CON_ID,24,14,266,29 + PUSHBUTTON "Write ID",IDC_BUTTON_CON_ID_WR,224,24,57,13 + EDITTEXT IDC_EDIT_CON_ID_0,35,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_1,58,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_2,81,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_3,104,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_4,127,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_5,150,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_6,173,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CON_ID_7,196,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + GROUPBOX "i.Link ID",IDC_STATIC_ILINK_ID,24,48,266,32 + PUSHBUTTON "Write ID",IDC_BUTTON_ILINK_ID_WR,224,58,57,13 EDITTEXT IDC_EDIT_ILINK_ID_0,35,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_ILINK_ID_1,59,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_ILINK_ID_1,58,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL EDITTEXT IDC_EDIT_ILINK_ID_2,81,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL EDITTEXT IDC_EDIT_ILINK_ID_3,104,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL EDITTEXT IDC_EDIT_ILINK_ID_4,127,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_ILINK_ID_5,149,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_ILINK_ID_6,171,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_ILINK_ID_7,192,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_6,170,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_CON_ID_7,191,24,19,14,ES_UPPERCASE | ES_AUTOHSCROLL - GROUPBOX "Model Name",IDC_STATIC_MODEL_NAME,25,84,263,31 - EDITTEXT IDC_EDIT_MODEL_NAME,35,94,176,14,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_ILINK_ID_5,150,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_ILINK_ID_6,173,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_ILINK_ID_7,196,58,19,14,ES_UPPERCASE | ES_AUTOHSCROLL + GROUPBOX "Model Name",IDC_STATIC_MODEL_NAME,24,84,266,31 PUSHBUTTON "Write ID",IDC_BUTTON_MODEL_NAME_WR,224,94,57,13 - PUSHBUTTON "Initialize MECHACON",IDC_BUTTON_INIT_MECHA,97,127,50,33,BS_MULTILINE + EDITTEXT IDC_EDIT_MODEL_NAME,35,94,180,14,ES_AUTOHSCROLL + GROUPBOX "Initialize Defaults",IDC_STATIC_INIT_DEFS,24,116,146,46 PUSHBUTTON "Initialize NTSC/PAL defaults",IDC_BUTTON_INIT_NTSCPAL_DEFS,39,126,50,33,BS_MULTILINE - GROUPBOX "Initialize Defaults",IDC_STATIC_INIT_DEFS,26,116,146,46 + PUSHBUTTON "Initialize MECHACON",IDC_BUTTON_INIT_MECHA,97,126,50,33,BS_MULTILINE + DEFPUSHBUTTON "Close",IDOK,230,147,50,13 END -IDD_DIALOG_CON_VER DIALOGEX 0, 0, 210, 72 +IDD_DIALOG_CON_VER DIALOGEX 0, 0, 150, 70 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Console Version" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,131,30,50,14 - LTEXT "CFC:",IDC_STATIC_LBL_CFC,25,23,17,8 - LTEXT "CFD:",IDC_STATIC_LBL_CFD,25,33,17,8 - LTEXT "ADD0x010:",IDC_STATIC_LBL_CON_VER,25,44,38,8 - LTEXT "Unknown",IDC_STATIC_CFC,75,23,30,8 - LTEXT "Unknown",IDC_STATIC_CFD,75,34,30,8 - LTEXT "Unknown",IDC_STATIC_CON_VER,75,45,30,8 - LTEXT "MD Version:",IDC_STATIC_LBL_MD_VER,25,13,39,8 - LTEXT "Unknown",IDC_STATIC_MD_VER,75,13,30,8 + LTEXT "MD Version:",IDC_STATIC_LBL_MD_VER,25,11,39,8 + LTEXT "Unknown",IDC_STATIC_MD_VER,75,11,50,8 + LTEXT "CFD:",IDC_STATIC_LBL_CFD,25,22,39,8 + LTEXT "Unknown",IDC_STATIC_CFD,75,22,50,8 + LTEXT "CFC:",IDC_STATIC_LBL_CFC,25,33,39,8 + LTEXT "Unknown",IDC_STATIC_CFC,75,33,50,8 + LTEXT "ADD0x010:",IDC_STATIC_LBL_CON_VER,25,44,39,8 + LTEXT "Unknown",IDC_STATIC_CON_VER,75,44,50,8 + // DEFPUSHBUTTON "OK",IDOK,131,30,50,14 END IDD_DIALOG_INIT_MECHA DIALOGEX 0, 0, 295, 181 diff --git a/PMAP-win/eeprom-main.c b/PMAP-wingui/eeprom-main.c similarity index 91% rename from PMAP-win/eeprom-main.c rename to PMAP-wingui/eeprom-main.c index f13a907..2a750f0 100644 --- a/PMAP-win/eeprom-main.c +++ b/PMAP-wingui/eeprom-main.c @@ -46,13 +46,13 @@ static void InitWindow(HWND hwnd) L"D-chassis (SCPH-300xx/SCPH-350xx)", L"F-chassis (SCPH-30000/SCPH-300xx R)", L"G-chassis (SCPH-390xx)", - L"H-chassis (SCPH-500xx)", + L"Dragon (SCPH-5x0xx--SCPH-900xx)", L"A-chassis (DTL-H10000)", // A L"A-chassis (DTL-T10000H)", // A2 L"A-chassis (DTL-T10000)", // A3 L"B-chassis (DTL-H30001/2 with Auto-Tilt motor)", L"D-chassis (DTL-H30x0x)", - L"H-chassis (DTL-H500xx)", + L"Dragon (DTL-5x0xx--DTL-900xx)", NULL}; combo = GetDlgItem(hwnd, IDC_CMB_CHASSIS); @@ -105,7 +105,7 @@ static int UpdateEEPROM(HWND hwndDlg) { do { - printf("Please select the optical block:\n" + PlatShowMessage("Please select the optical block:\n" "\t1. SONY\n" "\t2. SANYO\n" "Your choice: "); @@ -124,7 +124,7 @@ static int UpdateEEPROM(HWND hwndDlg) { do { - printf("Please select the object lens:\n" + PlatShowMessage("Please select the object lens:\n" "\t1. T487\n" "\t2. T609K\n" "Your choice: "); @@ -143,7 +143,7 @@ static int UpdateEEPROM(HWND hwndDlg) { do { - printf("The OSD2 init bit is set. Clear it? (y/n)"); + PlatShowMessage("The OSD2 init bit is set. Clear it? (y/n)"); choice = getchar(); while (getchar() != '\n') { @@ -154,35 +154,35 @@ static int UpdateEEPROM(HWND hwndDlg) if ((result = selected->update(ClearOSD2InitBit, ReplacedMecha, ObjectLens, OpticalBlock)) > 0) { - printf("Actions available:\n"); + PlatShowMessage("Actions available:\n"); if (result & UPDATE_REGION_EEP_ECR) - printf("\tEEPROM ECR\n"); + PlatShowMessage("\tEEPROM ECR\n"); if (result & UPDATE_REGION_DISCDET) - printf("\tDisc detect\n"); + PlatShowMessage("\tDisc detect\n"); if (result & UPDATE_REGION_SERVO) - printf("\tServo\n"); + PlatShowMessage("\tServo\n"); if (result & UPDATE_REGION_TILT) - printf("\tAuto-tilt\n"); + PlatShowMessage("\tAuto-tilt\n"); if (result & UPDATE_REGION_TRAY) - printf("\tTray\n"); + PlatShowMessage("\tTray\n"); if (result & UPDATE_REGION_EEGS) - printf("\tEE & GS\n"); + PlatShowMessage("\tEE & GS\n"); if (result & UPDATE_REGION_ECR) - printf("\tRTC ECR\n"); + PlatShowMessage("\tRTC ECR\n"); if (result & UPDATE_REGION_RTC) { - printf("\tRTC:\n"); + PlatShowMessage("\tRTC:\n"); if (result & UPDATE_REGION_RTC_CTL12) - printf("\t\tRTC CTL1,2 ERROR\n"); + PlatShowMessage("\t\tRTC CTL1,2 ERROR\n"); if (result & UPDATE_REGION_RTC_TIME) - printf("\t\tRTC TIME ERROR\n"); + PlatShowMessage("\t\tRTC TIME ERROR\n"); } if (result & UPDATE_REGION_DEFAULTS) - printf("\tMechacon defaults\n"); + PlatShowMessage("\tMechacon defaults\n"); do { - printf("Proceed with updates? (y/n) "); + PlatShowMessage("Proceed with updates? (y/n) "); choice = getchar(); while (getchar() != '\n') { @@ -200,14 +200,14 @@ static int UpdateEEPROM(HWND hwndDlg) } else { - printf("An error occurred. Wrong chassis selected?\n"); + PlatShowMessage("An error occurred. Wrong chassis selected?\n"); } return result; } else { - printf("Unsupported chassis selected.\n"); + PlatShowMessage("Unsupported chassis selected.\n"); return -EINVAL; } } @@ -228,6 +228,8 @@ static INT_PTR CALLBACK EepDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP case WM_COMMAND: switch (LOWORD(wParam)) { + case IDOK: + case IDCANCEL: case IDCLOSE: EndDialog(hwndDlg, TRUE); break; diff --git a/PMAP-win/elect-main.c b/PMAP-wingui/elect-main.c similarity index 91% rename from PMAP-win/elect-main.c rename to PMAP-wingui/elect-main.c index 8c4cb15..8d2479f 100644 --- a/PMAP-win/elect-main.c +++ b/PMAP-wingui/elect-main.c @@ -14,7 +14,7 @@ extern HINSTANCE g_hInstance; extern HWND g_mainWin; -extern unsigned char ElectConIsT10K, ConType; +extern unsigned char ElectConIsT10K, ConType, ConSlim; static void ToggleMainDialogControls(HWND hwnd, BOOL enabled) { @@ -54,13 +54,16 @@ static void InitWindow(HWND hwnd) SetWindowText(GetDlgItem(hwnd, IDC_ELECT_MECHACON), L"G: CXP103049 x.3.8.0"); break; case MECHA_TYPE_40: - SetWindowText(GetDlgItem(hwnd, IDC_ELECT_MECHACON), L"Dragons"); + if (ConSlim) + SetWindowText(GetDlgItem(hwnd, IDC_ELECT_MECHACON), L"Slims"); + else + SetWindowText(GetDlgItem(hwnd, IDC_ELECT_MECHACON), L"H,I,J,X: CXR706080"); break; default: SetWindowText(GetDlgItem(hwnd, IDC_ELECT_MECHACON), L"Unknown"); } - ToggleMainDialogControls(hwnd, FALSE); + ToggleMainDialogControls(hwnd, TRUE); } static INT_PTR CALLBACK ElectDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -81,15 +84,15 @@ static INT_PTR CALLBACK ElectDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM { case IDC_BTN_START: if (IsChassisDexA()) - { ElectConIsT10K = (IsDlgButtonChecked(hwndDlg, IDC_CHK_T10K) == BST_CHECKED); - } else ElectConIsT10K = 0; ToggleMainDialogControls(hwndDlg, FALSE); ElectAutoAdjust(); ToggleMainDialogControls(hwndDlg, TRUE); break; + case IDOK: + case IDCANCEL: case IDCLOSE: EndDialog(hwndDlg, TRUE); break; diff --git a/PMAP-win/id-main.c b/PMAP-wingui/id-main.c similarity index 83% rename from PMAP-win/id-main.c rename to PMAP-wingui/id-main.c index 794de55..cfd4a03 100644 --- a/PMAP-win/id-main.c +++ b/PMAP-wingui/id-main.c @@ -16,7 +16,7 @@ extern HWND g_mainWin; extern unsigned char ConType, ConCEXDEX; -static void InitMechacon(void) +/* static void InitMechacon(void) { int choice, done, dex, NumChoices; @@ -27,7 +27,7 @@ static void InitMechacon(void) { do { - printf("MECHACON initialization for H/I-chassis\n" + PlatShowMessage("MECHACON initialization for H/I-chassis\n" "Select type:\n" "\t1. CEX\n" "\t2. DEX\n" @@ -58,25 +58,27 @@ static void InitMechacon(void) { if (!dex) { - printf("Select model Name:\n" - "\t1. SCPH-50000\n" - "\t2. SCPH-50001\n" - "\t3. SCPH-50002\n" - "\t4. SCPH-50003\n" - "\t5. SCPH-50004\n" - "\t6. SCPH-50005\n" - "\t7. SCPH-50006\n" - "\t8. SCPH-50007\n" - "\t9. SCPH-50008\n" - "\t10. SCPH-50009\n" - "\t11. SCPH-50010\n" - "\t12. Quit\n" + PlatShowMessage("Select model Name:\n" + "\t1. SCPH-xx000 (Japan)\n" + "\t2. SCPH-xx001 (USA)\n" + "\t3. SCPH-xx002 (Australia)\n" + "\t4. SCPH-xx003 (Great Britian)\n" + "\t5. SCPH-xx004 (Europe)\n" + "\t6. SCPH-xx005 (Korea)\n" + "\t7. SCPH-xx006 (Hong Kong)\n" + "\t8. SCPH-xx007 (Taiwan)\n" + "\t9. SCPH-xx008 (Russia)\n" + "\t10. SCPH-50009 (China)\n" + "\t11. SCPH-xx010 (SCPH-50010: Canada, Slims: Mexico)\n" + "\t12. SCPH-x0011 (SCPH-50011: Mexico, SCPH-70011: USA)\n" + "\t13. SCPH-70012 (Canada)\n" + "\t14. Quit\n" "Your choice: "); NumChoices = 12; } else { - printf("Select model Name:\n" + PlatShowMessage("Select model Name:\n" "\t1. DTL-H50000\n" "\t2. DTL-H50001\n" "\t3. DTL-H50002\n" @@ -109,9 +111,11 @@ static void InitMechacon(void) case 9: case 10: case 11: - printf("MechaInit: %s\n", MechaInitMechacon(choice, 0) == 0 ? "done" : "failed"); - break; case 12: + case 13: + PlatShowMessage("MechaInit: %s\n", MechaInitMechacon(choice, 0) == 0 ? "done" : "failed"); + break; + case 14: done = 1; } } @@ -126,7 +130,7 @@ static void InitMechacon(void) case 5: case 6: case 7: - printf("MechaInit: %s\n", MechaInitMechacon(choice, 1) == 0 ? "done" : "failed"); + PlatShowMessage("MechaInit: %s\n", MechaInitMechacon(choice, 1) == 0 ? "done" : "failed"); break; case 8: done = 1; @@ -136,7 +140,7 @@ static void InitMechacon(void) } } else - printf("MechaInit: Unsupported chassis.\n"); + PlatShowMessage("MechaInit: Unsupported chassis.\n"); } static void InitNTSCPALDefaults(void) @@ -145,7 +149,7 @@ static void InitNTSCPALDefaults(void) do { - printf("NTSC/PAL selection:\n" + PlatShowMessage("NTSC/PAL selection:\n" "\t1. NTSC\n" "\t2. PAL\n" "\t3. Quit\n" @@ -160,13 +164,13 @@ static void InitNTSCPALDefaults(void) switch (choice) { case 1: - printf("Init NTSC defaults: %s\n", EEPROMNTSCPALDefaults(0) == 0 ? "completed" : "failed"); + PlatShowMessage("Init NTSC defaults: %s\n", EEPROMNTSCPALDefaults(0) == 0 ? "completed" : "failed"); break; case 2: - printf("Init PAL defaults: %s\n", EEPROMNTSCPALDefaults(1) == 0 ? "completed" : "failed"); + PlatShowMessage("Init PAL defaults: %s\n", EEPROMNTSCPALDefaults(1) == 0 ? "completed" : "failed"); break; } -} +} */ static INT_PTR CALLBACK InitNTSCPALDefsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -238,38 +242,38 @@ static void InitMenu(HWND hwnd) EEPROMGetiLinkID(iLinkID); EEPROMGetConsoleID(ConsoleID); - sprintf(value, "%02x", ConsoleID[0]); + snprintf(value, 3, "%02x", ConsoleID[0]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_0), value); - sprintf(value, "%02x", ConsoleID[1]); + snprintf(value, 3, "%02x", ConsoleID[1]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_1), value); - sprintf(value, "%02x", ConsoleID[2]); + snprintf(value, 3, "%02x", ConsoleID[2]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_2), value); - sprintf(value, "%02x", ConsoleID[3]); + snprintf(value, 3, "%02x", ConsoleID[3]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_3), value); - sprintf(value, "%02x", ConsoleID[4]); + snprintf(value, 3, "%02x", ConsoleID[4]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_4), value); - sprintf(value, "%02x", ConsoleID[5]); + snprintf(value, 3, "%02x", ConsoleID[5]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_5), value); - sprintf(value, "%02x", ConsoleID[6]); + snprintf(value, 3, "%02x", ConsoleID[6]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_6), value); - sprintf(value, "%02x", ConsoleID[7]); + snprintf(value, 3, "%02x", ConsoleID[7]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_CON_ID_7), value); - sprintf(value, "%02x", iLinkID[0]); + snprintf(value, 3, "%02x", iLinkID[0]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_0), value); - sprintf(value, "%02x", iLinkID[1]); + snprintf(value, 3, "%02x", iLinkID[1]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_1), value); - sprintf(value, "%02x", iLinkID[2]); + snprintf(value, 3, "%02x", iLinkID[2]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_2), value); - sprintf(value, "%02x", iLinkID[3]); + snprintf(value, 3, "%02x", iLinkID[3]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_3), value); - sprintf(value, "%02x", iLinkID[4]); + snprintf(value, 3, "%02x", iLinkID[4]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_4), value); - sprintf(value, "%02x", iLinkID[5]); + snprintf(value, 3, "%02x", iLinkID[5]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_5), value); - sprintf(value, "%02x", iLinkID[6]); + snprintf(value, 3, "%02x", iLinkID[6]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_6), value); - sprintf(value, "%02x", iLinkID[7]); + snprintf(value, 3, "%02x", iLinkID[7]); SetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_ILINK_ID_7), value); if (ConType != MECHA_TYPE_36) diff --git a/PMAP-win/mecha-main.c b/PMAP-wingui/mecha-main.c similarity index 88% rename from PMAP-win/mecha-main.c rename to PMAP-wingui/mecha-main.c index 6d2d0d2..6b44325 100644 --- a/PMAP-win/mecha-main.c +++ b/PMAP-wingui/mecha-main.c @@ -125,29 +125,29 @@ static int MechaAdjTxHandler(MechaTask_t *task) switch (DiscDetect) { case DISC_TYPE_CD12: - printf("Disc type CD 12cm\n"); + PlatShowMessage("Disc type CD 12cm\n"); task->command = MECHA_CMD_DISC_MODE_CD_12; status = MECHA_ADJ_STATE_CD; return 0; case DISC_TYPE_DVDS12: - printf("Disc type DVD-SL 12cm\n"); + PlatShowMessage("Disc type DVD-SL 12cm\n"); task->command = MECHA_CMD_DISC_MODE_DVDSL_12; status = MECHA_ADJ_STATE_DVDSL; return 0; case DISC_TYPE_DVDD12: - printf("Disc type DVD-DL 12cm\n"); + PlatShowMessage("Disc type DVD-DL 12cm\n"); task->command = MECHA_CMD_DISC_MODE_DVDDL_12; status = MECHA_ADJ_STATE_DVDDL; return 0; case DISC_TYPE_UNKNOWN: - printf("Disc type unknown.\n"); + PlatShowMessage("Disc type unknown.\n"); task->id = 0; task->tag = 0; task->command = 0; status = MECHA_ADJ_STATE_NONE; return 0; case DISC_TYPE_NO_DISC: - printf("No disc inserted.\n"); + PlatShowMessage("No disc inserted.\n"); task->id = 0; task->tag = 0; task->command = 0; @@ -155,7 +155,7 @@ static int MechaAdjTxHandler(MechaTask_t *task) return 0; default: status = MECHA_ADJ_STATE_NONE; - printf("Unsupported disc type: %02x\n", DiscDetect); + PlatShowMessage("Unsupported disc type: %02x\n", DiscDetect); return 1; } default: @@ -391,7 +391,7 @@ static int MechaAdjInit(short int argc, char *argv[]) case MECHA_TYPE_40: break; default: - printf("MechaAdjInit: Unsupported chassis.\n"); + PlatShowMessage("MechaAdjInit: Unsupported chassis.\n"); return 0; } @@ -414,7 +414,7 @@ static int MechaAdjInit(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1: case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: - printf("Please STOP the drive first! Currently in another PLAY mode.\n"); + PlatShowMessage("Please STOP the drive first! Currently in another PLAY mode.\n"); return 0; } @@ -441,7 +441,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "CD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("CD initialization failed.\n"); + PlatShowMessage("CD initialization failed.\n"); else status = MECHA_ADJ_STATE_CD; @@ -468,7 +468,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-SL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-SL initialization failed.\n"); + PlatShowMessage("DVD-SL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDSL; @@ -494,7 +494,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-DL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-DL initialization failed.\n"); + PlatShowMessage("DVD-DL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDDL; @@ -521,7 +521,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-SL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-SL initialization failed.\n"); + PlatShowMessage("DVD-SL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDSL; @@ -547,7 +547,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) switch (status) { case MECHA_ADJ_STATE_NONE: - printf("Please do initialization first!\n"); + PlatShowMessage("Please do initialization first!\n"); break; case MECHA_ADJ_STATE_DVDDL_PAUSE: case MECHA_ADJ_STATE_DVDDL_1: @@ -556,7 +556,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (!pstricmp(argv[1], "FJ")) { if ((result = MechaCommandExecute(MECHA_CMD_FOCUS_JUMP, 2000, "0300", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); break; } case MECHA_ADJ_STATE_DVDSL_PAUSE: @@ -569,7 +569,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_4: case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: - printf("Please STOP the drive. It is currently in PLAY mode.\n"); + PlatShowMessage("Please STOP the drive. It is currently in PLAY mode.\n"); break; case MECHA_ADJ_STATE_CD: speed = (int)strtol(argv[1], NULL, 0); @@ -597,7 +597,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) command = MECHA_CMD_CD_PLAY_5; break; default: - printf("Unsupported speed.\n"); + PlatShowMessage("Unsupported speed.\n"); timeout = 0; command = 0; } @@ -605,7 +605,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (command != 0) { if ((result = MechaCommandExecute(command, timeout, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else status += speed; @@ -631,7 +631,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) command = MECHA_CMD_DVD_PLAY_3; break; default: - printf("Unsupported speed.\n"); + PlatShowMessage("Unsupported speed.\n"); timeout = 0; command = 0; } @@ -639,7 +639,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (command != 0) { if ((result = MechaCommandExecute(command, timeout, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else status += speed; @@ -668,7 +668,7 @@ static int MechaAdjStop(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: if ((result = MechaCommandExecute(MECHA_CMD_CD_STOP, 4000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); status = MECHA_ADJ_STATE_CD; break; case MECHA_ADJ_STATE_DVDSL_PAUSE: @@ -680,7 +680,7 @@ static int MechaAdjStop(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: if ((result = MechaCommandExecute(MECHA_CMD_DVD_STOP, 5000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); switch (status) { @@ -699,7 +699,7 @@ static int MechaAdjStop(short int argc, char *argv[]) } break; default: - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } return 0; @@ -711,7 +711,7 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) if (!IsAutoTiltModel()) { - printf("This is not a B-chassis (non-auto-tilt motor model).\n"); + PlatShowMessage("This is not a B-chassis (non-auto-tilt motor model).\n"); return 0; } @@ -722,13 +722,13 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_INIT_AUTO_TILT, NULL, id++, 0, 5000, "AUTO TILT INIT"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "ADJ")) { MechaCommandAdd(MECHA_CMD_ADJ_AUTO_TILT, "00", id++, 0, 15000, "TILT ADJUST"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "WRITE")) { @@ -744,19 +744,19 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_WRITE_CHECKSUM, "00", id++, 0, 3000, "EEPROM WRITE CHECKSUM"); MechaCommandAdd(MECHA_CMD_READ_CHECKSUM, "00", id++, 0, 3000, "EEPROM READ CHECKSUM"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "REV")) { MechaCommandAdd(MECHA_CMD_MOV_AUTO_TILT, "000001", id++, 0, 5000, "TILT ADJUST REV"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "FWD")) { MechaCommandAdd(MECHA_CMD_MOV_AUTO_TILT, "010001", id++, 0, 5000, "TILT ADJUST FWD"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -777,7 +777,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_PAUSE: case MECHA_ADJ_STATE_DVDSL_PAUSE: case MECHA_ADJ_STATE_DVDDL_PAUSE: - printf("Already paused.\n"); + PlatShowMessage("Already paused.\n"); break; case MECHA_ADJ_STATE_CD_1: case MECHA_ADJ_STATE_CD_2: @@ -785,7 +785,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: if ((result = MechaCommandExecute(MECHA_CMD_CD_PAUSE, 3000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); break; case MECHA_ADJ_STATE_DVDSL_1: case MECHA_ADJ_STATE_DVDSL_1p6: @@ -794,7 +794,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: if ((result = MechaCommandExecute(MECHA_CMD_DVD_PAUSE, 5000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); switch (status) { @@ -811,7 +811,7 @@ static int MechaAdjPause(short int argc, char *argv[]) } break; default: - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } return 0; @@ -828,37 +828,37 @@ static int MechaAdjTray(short int argc, char *argv[]) { if (!SledIsAtHome) { - printf("Sled must be in home position!\n"); + PlatShowMessage("Sled must be in home position!\n"); return 0; } if ((result = MechaCommandExecute(MECHA_CMD_TRAY, 6000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[1], "OPEN")) { if (!SledIsAtHome) { - printf("Sled must be in home position!\n"); + PlatShowMessage("Sled must be in home position!\n"); return 0; } if ((result = MechaCommandExecute(MECHA_CMD_TRAY, 6000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[1], "IN-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_TRAY_SW, 3000, "00", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("IN-SW: %s\n", buffer); + PlatShowMessage("IN-SW: %s\n", buffer); } else if (!pstricmp(argv[1], "OUT-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_TRAY_SW, 3000, "01", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("OUT-SW: %s\n", buffer); + PlatShowMessage("OUT-SW: %s\n", buffer); } else return -EINVAL; @@ -879,23 +879,23 @@ static int MechaAdjJitter(short int argc, char *argv[]) if (!pstricmp(argv[1], "1")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 1000, "00", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else if (!pstricmp(argv[1], "16")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 1000, "02", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else if (!pstricmp(argv[1], "256")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 2000, "01", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else return -EINVAL; @@ -924,7 +924,7 @@ static int MechaAdjGetError(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_DSP_ERROR_RATE, "00", id++, MECHA_CMD_TAG_MECHA_DVD_ERROR_RATE, 2000, "DVD GET DSP ERROR RATE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) == 0) { - printf("DVD Error Data:\n" + PlatShowMessage("DVD Error Data:\n" "PI Correct:\t\t%#04x\tPO Correct:\t\t%#04x\n" "PI Non-correct:\t%#04x\tPO Non-correct:\t%#04x\n" "PI Max:\t\t\t%#04x\tPO Max:\t\t\t%#04x\n" @@ -934,10 +934,10 @@ static int MechaAdjGetError(short int argc, char *argv[]) DvdError.jitter); } else - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); break; default: - printf("Not in a DVD PLAY mode.\n"); + PlatShowMessage("Not in a DVD PLAY mode.\n"); } } else if (!pstricmp(argv[1], "CD")) @@ -952,13 +952,13 @@ static int MechaAdjGetError(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_CD_ERROR, "00", id++, MECHA_CMD_TAG_MECHA_CD_ERROR_RATE, 2000, "CD GET DSP ERROR RATE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) == 0) { - printf("%04x:::%04x\n", CdError.c1, CdError.c2); + PlatShowMessage("%04x:::%04x\n", CdError.c1, CdError.c2); } else - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); break; default: - printf("Not in a CD PLAY mode.\n"); + PlatShowMessage("Not in a CD PLAY mode.\n"); } } else @@ -977,26 +977,26 @@ static int MechaAdjSled(short int argc, char *argv[]) if (!pstricmp(argv[1], "HOME")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_POS_HOME, 3000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else SledIsAtHome = 1; } else if (!pstricmp(argv[1], "IN")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 2000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "OUT")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 3000, "02", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "MID")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 3000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "STEP-M")) @@ -1005,16 +1005,16 @@ static int MechaAdjSled(short int argc, char *argv[]) { if (!pstricmp(argv[2], "IN")) { // Micro reverse - sprintf(args, "00%04x", StepAmount); + snprintf(args, 7, "00%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_MICRO, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[2], "OUT")) { // Micro forward - sprintf(args, "01%04x", StepAmount); + snprintf(args, 7, "01%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_MICRO, 2000, "010064", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else @@ -1029,16 +1029,16 @@ static int MechaAdjSled(short int argc, char *argv[]) { if (!pstricmp(argv[2], "IN")) { // Biphs reverse - sprintf(args, "00%04x", StepAmount); + snprintf(args, 7, "00%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_BIPHS, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[2], "OUT")) { // Biphs forward - sprintf(args, "01%04x", StepAmount); + snprintf(args, 7, "01%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_BIPHS, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else @@ -1054,12 +1054,12 @@ static int MechaAdjSled(short int argc, char *argv[]) if (!pstricmp(argv[2], "ON")) { if ((result = MechaCommandExecute(MECHA_CMD_TRACKING, 1000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[2], "OFF")) { if ((result = MechaCommandExecute(MECHA_CMD_TRACKING, 1000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else return -EINVAL; @@ -1070,11 +1070,11 @@ static int MechaAdjSled(short int argc, char *argv[]) else if (!pstricmp(argv[1], "IN-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_IN_SW, 1000, NULL, buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { result = (int)strtoul(&buffer[1], NULL, 16); - printf("IN-SW: %02x\n", result); + PlatShowMessage("IN-SW: %02x\n", result); } } else if (!pstricmp(argv[1], "STEP")) @@ -1082,7 +1082,7 @@ static int MechaAdjSled(short int argc, char *argv[]) if (argc == 3) { StepAmount = (unsigned short int)strtoul(argv[2], NULL, 0); - printf("STEP: %u\n", StepAmount); + PlatShowMessage("STEP: %u\n", StepAmount); } else return -EINVAL; @@ -1103,10 +1103,10 @@ static int DisplayHelp(const struct MechaDiagCommand *commands, short int argc, if (argc == 1) { - printf("To get help for a specific command, type HELP \n" + PlatShowMessage("To get help for a specific command, type HELP \n" "Available commands:\n"); for (pCmd = commands, i = 0; pCmd->command != NULL; pCmd++, i++) - printf("\t%s%c", pCmd->command, (i != 0 && i % 4 == 0) ? '\n' : ' '); + PlatShowMessage("\t%s%c", pCmd->command, (i != 0 && i % 4 == 0) ? '\n' : ' '); putchar('\n'); } else if (argc == 2) @@ -1115,13 +1115,13 @@ static int DisplayHelp(const struct MechaDiagCommand *commands, short int argc, { if (!pstricmp(pCmd->command, argv[1])) { - printf("%s - %s\n", pCmd->syntax, pCmd->description); + PlatShowMessage("%s - %s\n", pCmd->syntax, pCmd->description); break; } } if (pCmd->command == NULL) - printf("No such command.\n"); + PlatShowMessage("No such command.\n"); } else { @@ -1158,7 +1158,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) if (!pstricmp(argv[1], "CD")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_CD_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_CD; @@ -1168,7 +1168,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) else if (!pstricmp(argv[1], "DVD-SL")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_DVDSL_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_DVDSL; @@ -1178,7 +1178,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) else if (!pstricmp(argv[1], "DVD-DL")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_DVDDL_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_DVDDL; @@ -1190,7 +1190,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_DISC_DETECT, NULL, id++, MECHA_CMD_TAG_MECHA_DISC_DETECT, 3000, "DISC DETECT"); MechaCommandAdd(MECHA_CMD_DISC_MODE_CD_8, NULL, id++, MECHA_CMD_TAG_MECHA_SET_DISC_TYPE, 1000, "DISC MODE CD 8cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1212,13 +1212,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_LASER_DIODE, "01", id++, 0, 3000, "LD ON"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "OFF")) { MechaCommandAdd(MECHA_CMD_LASER_DIODE, "00", id++, 0, 3000, "LD OFF"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1235,13 +1235,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "01", id++, 0, 3000, "FOCUS UP/DOWN START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[3], "STOP")) { MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "FOCUS UP/DOWN STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1252,13 +1252,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_AUTO_START, NULL, id++, 0, 3000, "AUTO FOCUS START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[3], "STOP")) { MechaCommandAdd(MECHA_CMD_FOCUS_AUTO_STOP, NULL, id++, 0, 3000, "AUTO FOCUS STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1284,7 +1284,7 @@ static int MechaTestServoControl(short int argc, char *argv[]) if (DiscDetect == 0xFF) { - printf("Disc type/circuit not set up!\n"); + PlatShowMessage("Disc type/circuit not set up!\n"); return 0; } @@ -1296,7 +1296,7 @@ static int MechaTestServoControl(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_SLED_POS_HOME, NULL, id++, 0, 3000, "SLED HOME"); MechaCommandAdd(MECHA_CMD_AUTO_ADJ_ST_12, "00", id++, 0, 40000, "SERVO AUTO ADJ START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1313,7 +1313,7 @@ static int MechaTestPlay(short int argc, char *argv[]) if (DiscDetect == 0xFF) { - printf("Disc type/circuit not set up!\n"); + PlatShowMessage("Disc type/circuit not set up!\n"); return 0; } @@ -1327,7 +1327,7 @@ static int MechaTestPlay(short int argc, char *argv[]) case DISC_TYPE_CD12: MechaCommandAdd(MECHA_CMD_CD_PLAY_1, NULL, id++, 0, 3000, "PLAY CD 12cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); else status = MECHA_ADJ_STATE_CD_1; break; @@ -1335,7 +1335,7 @@ static int MechaTestPlay(short int argc, char *argv[]) case DISC_TYPE_DVDD12: MechaCommandAdd(MECHA_CMD_DVD_PLAY_1, NULL, id++, 0, 5000, "PLAY DVD 12cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); else { switch (DiscDetect) @@ -1359,10 +1359,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_CTL, "01000A", id++, 0, 5000, "CD FWD 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1370,10 +1370,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_CTL, "01000A", id++, 0, 5000, "DVD FWD 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "REV")) @@ -1385,10 +1385,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_CTL, "00000A", id++, 0, 5000, "CD REV 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1396,10 +1396,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_CTL, "00000A", id++, 0, 5000, "DVD REV 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "FWDL")) @@ -1411,10 +1411,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_LONG_CTL, "010001", id++, 0, 10000, "CD FWD LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1422,10 +1422,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_LONG_CTL, "010001", id++, 0, 10000, "DVD FWD LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "REVL")) @@ -1437,10 +1437,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_LONG_CTL, "000001", id++, 0, 10000, "CD REV LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1448,10 +1448,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_LONG_CTL, "000001", id++, 0, 10000, "DVD REV LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "STOP")) @@ -1463,12 +1463,12 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_STOP, NULL, id++, 0, 20000, "CD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); status = MECHA_ADJ_STATE_CD; } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1476,7 +1476,7 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_STOP, NULL, id++, 0, 20000, "DVD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); switch (status) { @@ -1488,7 +1488,7 @@ static int MechaTestPlay(short int argc, char *argv[]) } } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "FJ")) @@ -1499,13 +1499,13 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_JUMP, "0205", id++, 0, 2000, "DVD-DL FOCUS JUMP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } else - printf("Not a DVD-DL.\n"); + PlatShowMessage("Not a DVD-DL.\n"); } else return -EINVAL; @@ -1527,31 +1527,31 @@ static int MechaTestSpindle(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_SP_CTL, "01", id++, 0, 3000, "SP KICK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "BRAKE")) { MechaCommandAdd(MECHA_CMD_SP_CTL, "00", id++, 0, 3000, "SP BRAKE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "STOP")) { MechaCommandAdd(MECHA_CMD_SP_CTL, "02", id++, 0, 3000, "SP STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "CLV-S")) { MechaCommandAdd(MECHA_CMD_SP_CLV_S, NULL, id++, 0, 3000, "SP CLV-S"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "CLV-A")) { MechaCommandAdd(MECHA_CMD_SP_CLV_A, NULL, id++, 0, 3000, "SP CLV-A"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1579,7 +1579,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt previous[0] = '\0'; do { - printf("MD1.%d %c> ", md, prompt); + PlatShowMessage("MD1.%d %c> ", md, prompt); if (fgets(input, sizeof(input), stdin)) { input[strlen(input) - 1] = '\0'; @@ -1605,7 +1605,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt if ((result = pCmd->function(argc, argv)) < 0) { if (result == -EINVAL) - printf(MECHA_ADJ_SYNTAX_ERR); + PlatShowMessage(MECHA_ADJ_SYNTAX_ERR); } else { @@ -1613,7 +1613,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt } } else - printf("Unrecognized command. For help, type HELP.\n"); + PlatShowMessage("Unrecognized command. For help, type HELP.\n"); } } while (!done); } @@ -1633,7 +1633,7 @@ static int MechaAdjPromptT10K(void) char input; do { - printf("Is this a DTL-T10000? [y,n] "); + PlatShowMessage("Is this a DTL-T10000? [y,n] "); input = getchar(); while (getchar() != '\n') { @@ -1665,6 +1665,8 @@ static INT_PTR CALLBACK MechaDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM // Test mechanics // MechaTestMain(); + case IDOK: + case IDCANCEL: case IDCLOSE: EndDialog(hwndDlg, TRUE); break; diff --git a/PMAP-win/platform.c b/PMAP-wingui/platform-wingui.c similarity index 68% rename from PMAP-win/platform.c rename to PMAP-wingui/platform-wingui.c index e46a5b6..bfdb1e1 100644 --- a/PMAP-win/platform.c +++ b/PMAP-wingui/platform-wingui.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "platform.h" #include "mecha.h" @@ -13,8 +15,27 @@ static HANDLE ComPortHandle = INVALID_HANDLE_VALUE; static unsigned short RxTimeout; static FILE *DebugOutputFile = NULL; +/* void ListSerialDevices() +{ + char targetPath[256]; + char dosDeviceName[256]; + char comPortName[] = "COM"; + + for (int portNum = 1; portNum <= 256; portNum++) + { + snprintf(dosDeviceName, sizeof(dosDeviceName), "%s%d", comPortName, portNum); + + if (QueryDosDevice(dosDeviceName, targetPath, sizeof(targetPath)) != 0) + { + PlatShowMessage("Found COM Port: %s\n", dosDeviceName); + PlatShowMessage("Target Path: %s\n", targetPath); + } + } +} */ + int PlatOpenCOMPort(const char *device) { + // ListSerialDevices(); COMMTIMEOUTS CommTimeout; DCB DeviceControlBlock; int result; @@ -27,8 +48,8 @@ int PlatOpenCOMPort(const char *device) DeviceControlBlock.DCBlength = sizeof(DCB); GetCommState(ComPortHandle, &DeviceControlBlock); DeviceControlBlock.BaudRate = CBR_57600; - DeviceControlBlock.ByteSize = 8; DeviceControlBlock.fParity = FALSE; + DeviceControlBlock.ByteSize = 8; DeviceControlBlock.StopBits = ONESTOPBIT; SetCommState(ComPortHandle, &DeviceControlBlock); CommTimeout.ReadIntervalTimeout = 0; @@ -46,6 +67,9 @@ int PlatOpenCOMPort(const char *device) else result = EMFILE; + if (result != 0) + PlatCloseCOMPort(); + return result; } @@ -82,13 +106,27 @@ int PlatWriteCOMPort(const char *data) else result = -EIO; + if (result < 0) + { + PlatShowMessage("Write to COM port failed.\n"); + } + return result; } void PlatCloseCOMPort(void) { - CloseHandle(ComPortHandle); - ComPortHandle = INVALID_HANDLE_VALUE; + if (ComPortHandle != INVALID_HANDLE_VALUE) + { + PlatShowMessage("Closing COM port...\n"); + CloseHandle(ComPortHandle); + ComPortHandle = INVALID_HANDLE_VALUE; + PlatShowMessage("COM port closed.\n"); + } + else + { + PlatShowMessage("COM port is already closed.\n"); + } } void PlatSleep(unsigned short int msec) @@ -106,9 +144,7 @@ void PlatShowEMessage(const char *format, ...) if (DebugOutputFile != NULL) vfprintf(DebugOutputFile, format, args); - MessageBoxA(g_mainWin, buffer, - "Error", - MB_OK | MB_ICONERROR); + MessageBoxA(g_mainWin, buffer, "Error", MB_OK | MB_ICONERROR); va_end(args); } @@ -123,15 +159,42 @@ void PlatShowMessage(const char *format, ...) if (DebugOutputFile != NULL) vfprintf(DebugOutputFile, format, args); - MessageBoxA(g_mainWin, buffer, - "Information", - MB_OK | MB_ICONINFORMATION); + MessageBoxA(g_mainWin, buffer, "Information", MB_OK | MB_ICONINFORMATION); + va_end(args); +} + +void PlatShowMessageB(const char *format, ...) +{ + char buffer[256]; + va_list args; + + va_start(args, format); + vsnprintf(buffer, sizeof(buffer), format, args); + if (DebugOutputFile != NULL) + vfprintf(DebugOutputFile, format, args); + + MessageBoxA(g_mainWin, buffer, "Information", MB_OK | MB_ICONINFORMATION); va_end(args); } void PlatDebugInit(void) { - DebugOutputFile = fopen("pmap.log", "w"); + // Get the current time + time_t rawtime; + struct tm *timeinfo; + char timestamp[20]; // Adjust the size according to your needs + + time(&rawtime); + timeinfo = localtime(&rawtime); + + // Format the timestamp (e.g., "2023-10-14_12-34-56") + strftime(timestamp, sizeof(timestamp), "%Y-%m-%d_%H-%M-%S", timeinfo); + + // Create the filename with timestamp + char filename[256]; // Adjust the size according to your needs + snprintf(filename, sizeof(filename), "pmap_%s.log", timestamp); + + DebugOutputFile = fopen(filename, "w"); } void PlatDebugDeinit(void) diff --git a/PMAP-win/resource.h b/PMAP-wingui/resource.h similarity index 100% rename from PMAP-win/resource.h rename to PMAP-wingui/resource.h diff --git a/PMAP-win/winmain.c b/PMAP-wingui/winmain.c similarity index 93% rename from PMAP-win/winmain.c rename to PMAP-wingui/winmain.c index bb7bb9a..691c9de 100644 --- a/PMAP-win/winmain.c +++ b/PMAP-wingui/winmain.c @@ -9,6 +9,7 @@ #include "main.h" #include "mecha.h" #include "eeprom.h" +#include "eeprom-id.h" #include "resource.h" HINSTANCE g_hInstance; @@ -31,13 +32,13 @@ static void InitRawConVerInfoMenu(HWND hwnd) MechaGetMode(&tm, &md); RawData = MechaGetRawIdent(); - sprintf(buffer, "TestMode.%d MD1.%d", tm, md); + snprintf(buffer, sizeof(buffer), "TestMode.%d MD1.%d", tm, md); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_MD_VER), buffer); - sprintf(buffer, "0x%08x", RawData->cfc); - SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_CFC), buffer); - sprintf(buffer, "0x%p", RawData->cfd); + snprintf(buffer, sizeof(buffer), "0x%s", RawData->cfd); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_CFD), buffer); - sprintf(buffer, "0x%04x", RawData->VersionID); + snprintf(buffer, sizeof(buffer), "%#08x", RawData->cfc); + SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_CFC), buffer); + snprintf(buffer, sizeof(buffer), "%#04x", RawData->VersionID); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_CON_VER), buffer); } @@ -114,7 +115,7 @@ static void InitConsoleInfo(HWND hwnd) char buffer[32]; MechaGetMode(&tm, &md); - sprintf(buffer, "TestMode.%d MD1.%d", tm, md); + snprintf(buffer, sizeof(buffer), "TestMode.%d MD1.%d", tm, md); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_MD_VER), buffer); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_MECHACON), MechaGetDesc()); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_CEXDEX), MechaGetCEXDEX() == 0 ? "DEX" : "CEX"); @@ -130,11 +131,11 @@ static void InitConsoleInfo(HWND hwnd) if (EEPROMInitSerial() == MECHA_RTC_RICOH) { EEPROMGetSerial(&serial, &emcs); - sprintf(buffer, "%07u", serial); + snprintf(buffer, sizeof(buffer), "%07u", serial); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_SERIAL), buffer); - sprintf(buffer, "%02x", emcs); + snprintf(buffer, sizeof(buffer), "%02x", emcs); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_EMCS_ID), buffer); - sprintf(buffer, "%04x", EEPROMGetModelID()); + snprintf(buffer, sizeof(buffer), "%04x", EEPROMGetModelID()); SetWindowTextA(GetDlgItem(hwnd, IDC_STATIC_MODEL_ID), buffer); } else @@ -243,6 +244,8 @@ static INT_PTR CALLBACK MainDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l case IDC_BUTTON_SHOW_VER: DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_CON_VER), hwndDlg, &ShowRawConVerInfoDlg); break; + case IDOK: + case IDCANCEL: case IDCLOSE: PlatCloseCOMPort(); PlatDebugDeinit(); diff --git a/PMAP.sln b/PMAP.sln index 5967546..fb84f93 100644 --- a/PMAP.sln +++ b/PMAP.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PMAP", "PMAP\PMAP.vcxproj", "{0E04D283-E9CF-4B50-AB74-887A62600457}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PMAP", "PMAP-wincli\PMAP.vcxproj", "{0E04D283-E9CF-4B50-AB74-887A62600457}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PMAP-win", "PMAP-win\PMAP-win.vcxproj", "{3346DB95-2EEB-4496-89B2-F2B9936B075D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PMAP-win", "PMAP-wingui\PMAP-win.vcxproj", "{3346DB95-2EEB-4496-89B2-F2B9936B075D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/base/eeprom-id.c b/base/eeprom-id.c new file mode 100644 index 0000000..1fcb81f --- /dev/null +++ b/base/eeprom-id.c @@ -0,0 +1,343 @@ +#include +#include +#include +#include +#include + +#include "platform.h" +#include "mecha.h" +#include "eeprom.h" +#include "eeprom-id.h" + +u8 iLinkID[8], ConsoleID[8]; +extern char ConModelName[17]; +extern unsigned char ConMD; + +static int EEPROMIDSaveiLinkID(const char *data, int len, int offset) +{ + u16 word; + + word = (u16)strtoul(&data[5], NULL, 16); + iLinkID[offset + 1] = word >> 8 & 0xFF; + iLinkID[offset] = word & 0xFF; + return 0; +} + +static int EEPROMIDSaveConsoleID(const char *data, int len, int offset) +{ + u16 word; + + word = (u16)strtoul(&data[5], NULL, 16); + ConsoleID[offset + 1] = word >> 8 & 0xFF; + ConsoleID[offset] = word & 0xFF; + return 0; +} + +static int EEPROMIDRxHandler(MechaTask_t *task, const char *result, short int len) +{ + switch (result[0]) + { + case '0': // Rx-OK + switch (task->tag) + { + case MECHA_CMD_TAG_INIT_ID_ILINK_ID_0: + return EEPROMIDSaveiLinkID(result, len, 0); + case MECHA_CMD_TAG_INIT_ID_ILINK_ID_1: + return EEPROMIDSaveiLinkID(result, len, 2); + case MECHA_CMD_TAG_INIT_ID_ILINK_ID_2: + return EEPROMIDSaveiLinkID(result, len, 4); + case MECHA_CMD_TAG_INIT_ID_ILINK_ID_3: + return EEPROMIDSaveiLinkID(result, len, 6); + case MECHA_CMD_TAG_INIT_ID_CON_ID_0: + return EEPROMIDSaveConsoleID(result, len, 0); + case MECHA_CMD_TAG_INIT_ID_CON_ID_1: + return EEPROMIDSaveConsoleID(result, len, 2); + case MECHA_CMD_TAG_INIT_ID_CON_ID_2: + return EEPROMIDSaveConsoleID(result, len, 4); + case MECHA_CMD_TAG_INIT_ID_CON_ID_3: + return EEPROMIDSaveConsoleID(result, len, 6); + default: + return 0; + } + break; + case '1': // Rx-NGErr + switch (task->tag) + { + default: + return MechaDefaultHandleRes1(task, result, len); + } + break; + case '2': // Rx-NGBadCmd + switch (task->tag) + { + default: + return MechaDefaultHandleRes2(task, result, len); + } + default: + return MechaDefaultHandleResUnknown(task, result, len); + } +} + +struct RegionData +{ + u8 region, vmode; +}; + +int MechaInitMechacon(int model, int IsDex) +{ + const struct RegionData CEXregions[] = { + {0, 0}, // 00 Japan + {1, 0}, // 01 USA + {3, 1}, // 02 Australia + {2, 1}, // 03 Great Britian + {2, 1}, // 04 Europe + {4, 0}, // 05 Korea + {4, 0}, // 06 Hong Kong + {4, 0}, // 07 Taiwan + {5, 1}, // 08 Russia + {6, 0}, // 09 Mainland China + {1, 0}, // 10 Canada (PAL or NTSC ??) + {7, 0}, // 11 Mexico + }; + const struct RegionData DEXregions[] = { + {0, 0}, // 00 + {1, 0}, // 01 + {1, 1}, // 02 + {0, 0}, // 05 + {0, 0}, // 06 + {1, 1}, // 08 + {6, 0}, // 09 + }; + time_t TimeNow; + struct tm *tm; + const struct RegionData *region; + char data[26]; + unsigned char id; + + region = IsDex ? &DEXregions[model] : &CEXregions[model]; + id = 1; + MechaCommandAdd(MECHA_TASK_UI_CMD_WAIT, NULL, MECHA_TASK_ID_UI, 0, 100, "EEPROM WAIT 100ms"); + /* if(MechaIdentRaw.cfc == 0x00000000) //Check that the MECHACON ID is 0. Not sure why it's necessary (may be either a safety check for their UI, or might be to prevent reassignments from taking place). + { */ + if (IsDex) + { + MechaCommandAdd(MECHA_CMD_INIT_MECHACON, "0001", id++, 0, 6000, "WR INIT DEX"); + MechaCommandAdd(MECHA_TASK_UI_CMD_WAIT, NULL, MECHA_TASK_ID_UI, 0, 100, "EEPROM WAIT 100ms"); + } + + time(&TimeNow); + srand((unsigned int)TimeNow); + tm = localtime(&TimeNow); + // Format: RRYYMMDDHHMMSSrrrr, where R = MagicGate region, Y = Year (from 2000), M = Month (1-12), D = Day of month (1-31), H = Hour (0-23), M = minute (0-59), S = second (0-59), r = random number (first 4 digits from the right). + // The time and date format is made with Ctime::Format %y%m%d%H%M%S + snprintf(data, 19, "%02x%02d%02d%02d%02d%02d%02d%04d", region->region, tm->tm_year - 100, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, rand() % 10000); + PlatShowMessage("Shimuke: %s (%zu)\n", data, strlen(data)); + MechaCommandAdd(MECHA_CMD_INIT_SHIMUKE, data, id++, 0, 6000, "WR INIT SHIMUKE"); + MechaCommandAdd(MECHA_TASK_UI_CMD_WAIT, NULL, MECHA_TASK_ID_UI, 0, 100, "EEPROM WAIT 100ms"); + // } + MechaCommandAdd(MECHA_CMD_CLEAR_CONF, "00", id++, 0, 6000, "WR INIT ALL DEFAULT"); + MechaCommandAdd(MECHA_TASK_UI_CMD_WAIT, NULL, MECHA_TASK_ID_UI, 0, 100, "EEPROM WAIT 100ms"); + if (region->vmode == 0) + MechaCommandAdd(MECHA_CMD_SETUP_OSD, "00", id++, 0, 6000, "WR INIT NTSC"); + else + MechaCommandAdd(MECHA_CMD_SETUP_OSD, "01", id++, 0, 6000, "WR INIT PAL"); + MechaCommandAdd(MECHA_TASK_UI_CMD_WAIT, NULL, MECHA_TASK_ID_UI, 0, 100, "EEPROM WAIT 100ms"); + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} + +int EEPROMNTSCPALDefaults(int vmode) +{ + u8 id; + + id = 1; + if (vmode == 0) + MechaCommandAdd(MECHA_CMD_SETUP_OSD, "00", id++, 0, 6000, "WR INIT NTSC"); + else + MechaCommandAdd(MECHA_CMD_SETUP_OSD, "01", id++, 0, 6000, "WR INIT PAL"); + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} + +int EEPROMInitID(void) +{ + char address[5]; + unsigned char id; + + memset(iLinkID, 0, sizeof(iLinkID)); + memset(ConsoleID, 0, sizeof(ConsoleID)); + + id = 1; + if (ConMD == 40) + { + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_NEW_0); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_0, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_NEW_1); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_1, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_NEW_2); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_2, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_NEW_3); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_3, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_NEW_0); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_0, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_NEW_1); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_1, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_NEW_2); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_2, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_NEW_3); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_3, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + } + else + { + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_0); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_0, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_1); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_1, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_2); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_2, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_ILINK_ID_3); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_ILINK_ID_3, MECHA_TASK_NORMAL_TO, "i.Link ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_0); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_0, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_1); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_1, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_2); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_2, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + snprintf(address, 5, "%04x", EEPROM_MAP_CON_ID_3); + MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_INIT_ID_CON_ID_3, MECHA_TASK_NORMAL_TO, "CONSOLE ID READ"); + } + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} + +void EEPROMGetiLinkID(u8 *id) +{ + memcpy(id, iLinkID, sizeof(iLinkID)); +} + +void EEPROMGetConsoleID(u8 *id) +{ + memcpy(id, ConsoleID, sizeof(ConsoleID)); +} + +int EEPROMSetiLinkID(const u8 *NewiLinkID) +{ + char arg[9]; + unsigned char id; + + memcpy(iLinkID, NewiLinkID, sizeof(iLinkID)); + + id = 1; + if (ConMD == 40) + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_NEW_0, iLinkID[1], iLinkID[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_NEW_1, iLinkID[3], iLinkID[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_NEW_2, iLinkID[5], iLinkID[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_NEW_3, iLinkID[7], iLinkID[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + } + else + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_0, iLinkID[1], iLinkID[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_1, iLinkID[3], iLinkID[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_2, iLinkID[5], iLinkID[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_ILINK_ID_3, iLinkID[7], iLinkID[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "i.Link ID WRITE"); + } + MechaAddPostEEPROMWrCmds(id); + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} + +int EEPROMSetConsoleID(const u8 *NewConID) +{ + char arg[9]; + unsigned char id; + + memcpy(ConsoleID, NewConID, sizeof(ConsoleID)); + + id = 1; + if (ConMD == 40) + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_NEW_0, ConsoleID[1], ConsoleID[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_NEW_1, ConsoleID[3], ConsoleID[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_NEW_2, ConsoleID[5], ConsoleID[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_NEW_3, ConsoleID[7], ConsoleID[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + } + else + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_0, ConsoleID[1], ConsoleID[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_1, ConsoleID[3], ConsoleID[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_2, ConsoleID[5], ConsoleID[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_CON_ID_3, ConsoleID[7], ConsoleID[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "CONSOLE ID WRITE"); + } + MechaAddPostEEPROMWrCmds(id); + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} + +int EEPROMSetModelName(const char *ModelName) +{ + char arg[9]; + unsigned char id; + + memset(ConModelName, 0, sizeof(ConModelName)); + strncpy(ConModelName, ModelName, sizeof(ConModelName) - 1); + + id = 1; + if (ConMD == 40) + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_0, ConModelName[1], ConModelName[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_1, ConModelName[3], ConModelName[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_2, ConModelName[5], ConModelName[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_3, ConModelName[7], ConModelName[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_4, ConModelName[9], ConModelName[8]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_5, ConModelName[11], ConModelName[10]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_6, ConModelName[13], ConModelName[12]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_NEW_7, ConModelName[15], ConModelName[14]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + } + else + { + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_0, ConModelName[1], ConModelName[0]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_1, ConModelName[3], ConModelName[2]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_2, ConModelName[5], ConModelName[4]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_3, ConModelName[7], ConModelName[6]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_4, ConModelName[9], ConModelName[8]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_5, ConModelName[11], ConModelName[10]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_6, ConModelName[13], ConModelName[12]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + snprintf(arg, 9, "%04x%02x%02x", EEPROM_MAP_MODEL_NAME_7, ConModelName[15], ConModelName[14]); + MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, arg, id++, 0, MECHA_TASK_NORMAL_TO, "MODEL NAME WRITE"); + } + MechaAddPostEEPROMWrCmds(id); + + return MechaCommandExecuteList(NULL, &EEPROMIDRxHandler); +} diff --git a/base/eeprom-id.h b/base/eeprom-id.h new file mode 100644 index 0000000..5bc9a28 --- /dev/null +++ b/base/eeprom-id.h @@ -0,0 +1,9 @@ +int EEPROMInitID(void); +int MechaInitMechacon(int model, int IsDex); +int EEPROMNTSCPALDefaults(int vmode); + +void EEPROMGetiLinkID(u8 *id); +void EEPROMGetConsoleID(u8 *id); +int EEPROMSetiLinkID(const u8 *NewiLinkID); +int EEPROMSetConsoleID(const u8 *NewConID); +int EEPROMSetModelName(const char *ModelName); diff --git a/base/eeprom-main.c b/base/eeprom-main.c index 8594341..58981ef 100644 --- a/base/eeprom-main.c +++ b/base/eeprom-main.c @@ -16,13 +16,13 @@ static int DumpEEPROM(const char *filename) int i, progress, result; u16 data; - printf("\nDumping EEPROM:\n"); + PlatShowMessage("\nDumping EEPROM:\n"); if ((dump = fopen(filename, "wb")) != NULL) { for (i = 0; i < 1024 / 2; i++) { putchar('\r'); - printf("Progress: "); + PlatShowMessage("Progress: "); putchar('['); for (progress = 0; progress <= (i * 20 / 512); progress++) putchar('#'); @@ -32,7 +32,7 @@ static int DumpEEPROM(const char *filename) if ((result = EEPROMReadWord(i, &data)) != 0) { - printf("EEPROM read error %d:%d\n", i, result); + PlatShowMessage("EEPROM read error %d:%d\n", i, result); break; } if (fwrite(&data, sizeof(u16), 1, dump) != 1) @@ -54,13 +54,13 @@ static int RestoreEEPROM(const char *filename) int i, progress, result; u16 data; - printf("\nRestoring EEPROM:\n"); + PlatShowMessage("\nRestoring EEPROM:\n"); if ((dump = fopen(filename, "rb")) != NULL) { for (i = 0; i < 1024 / 2; i++) { putchar('\r'); - printf("Progress: "); + PlatShowMessage("Progress: "); putchar('['); for (progress = 0; progress <= (i * 20 / 512); progress++) putchar('#'); @@ -73,7 +73,7 @@ static int RestoreEEPROM(const char *filename) if ((result = EEPROMWriteWord(i, data)) != 0) { - printf("EEPROM write error %d:%d\n", i, result); + PlatShowMessage("EEPROM write error %d:%d\n", i, result); break; } } @@ -118,14 +118,14 @@ static int UpdateEEPROM(int chassis) {&MechaUpdateChassisDexH, EEPROM_UPDATE_FLAG_SANYO | EEPROM_UPDATE_FLAG_NEW_SONY}, }; - printf("Update EEPROM\n\n"); + PlatShowMessage("Update EEPROM\n\n"); if (chassis >= 0) { selected = &data[chassis]; do { - printf("Was the MECHACON replaced (y/n)? "); + PlatShowMessage("Was the MECHACON replaced (y/n)? "); choice = getchar(); while (getchar() != '\n') { @@ -137,7 +137,7 @@ static int UpdateEEPROM(int chassis) { do { - printf("Please select the optical block:\n" + PlatShowMessage("Please select the optical block:\n" "\t1. SONY\n" "\t2. SANYO\n" "Your choice: "); @@ -156,7 +156,7 @@ static int UpdateEEPROM(int chassis) { do { - printf("Please select the object lens:\n" + PlatShowMessage("Please select the object lens:\n" "\t1. T487\n" "\t2. T609K\n" "Your choice: "); @@ -175,7 +175,7 @@ static int UpdateEEPROM(int chassis) { do { - printf("The OSD2 init bit is set. Clear it? (y/n)"); + PlatShowMessage("The OSD2 init bit is set. Clear it? (y/n)"); choice = getchar(); while (getchar() != '\n') { @@ -188,35 +188,35 @@ static int UpdateEEPROM(int chassis) if ((result = selected->update(ClearOSD2InitBit, ReplacedMecha, ObjectLens, OpticalBlock)) > 0) { - printf("Actions available:\n"); + PlatShowMessage("Actions available:\n"); if (result & UPDATE_REGION_EEP_ECR) - printf("\tEEPROM ECR\n"); + PlatShowMessage("\tEEPROM ECR\n"); if (result & UPDATE_REGION_DISCDET) - printf("\tDisc detect\n"); + PlatShowMessage("\tDisc detect\n"); if (result & UPDATE_REGION_SERVO) - printf("\tServo\n"); + PlatShowMessage("\tServo\n"); if (result & UPDATE_REGION_TILT) - printf("\tAuto-tilt\n"); + PlatShowMessage("\tAuto-tilt\n"); if (result & UPDATE_REGION_TRAY) - printf("\tTray\n"); + PlatShowMessage("\tTray\n"); if (result & UPDATE_REGION_EEGS) - printf("\tEE & GS\n"); + PlatShowMessage("\tEE & GS\n"); if (result & UPDATE_REGION_ECR) - printf("\tRTC ECR\n"); + PlatShowMessage("\tRTC ECR\n"); if (result & UPDATE_REGION_RTC) { - printf("\tRTC:\n"); + PlatShowMessage("\tRTC:\n"); if (result & UPDATE_REGION_RTC_CTL12) - printf("\t\tRTC CTL1,2 ERROR\n"); + PlatShowMessage("\t\tRTC CTL1,2 ERROR\n"); if (result & UPDATE_REGION_RTC_TIME) - printf("\t\tRTC TIME ERROR\n"); + PlatShowMessage("\t\tRTC TIME ERROR\n"); } if (result & UPDATE_REGION_DEFAULTS) - printf("\tMechacon defaults\n"); + PlatShowMessage("\tMechacon defaults\n"); do { - printf("Proceed with updates? (y/n) "); + PlatShowMessage("Proceed with updates? (y/n) "); choice = getchar(); while (getchar() != '\n') { @@ -234,14 +234,14 @@ static int UpdateEEPROM(int chassis) } else { - printf("An error occurred. Wrong chassis selected?, result = %d\n", result); + PlatShowMessage("An error occurred. Wrong chassis selected?, result = %d\n", result); } return result; } else { - printf("Unsupported chassis selected.\n"); + PlatShowMessage("Unsupported chassis selected.\n"); return -EINVAL; } } @@ -263,22 +263,22 @@ static int SelectChassis(void) {&IsChassisD, "D-chassis (SCPH-300xx/SCPH-350xx)"}, {&IsChassisF, "F-chassis (SCPH-30000/SCPH-300xx R)"}, {&IsChassisG, "G-chassis (SCPH-390xx)"}, - {&IsChassisDragon, "Dragon (SCPH-500xx--SCPH-900xx)"}, + {&IsChassisDragon, "Dragon (SCPH-5x0xx--SCPH-900xx)"}, {&IsChassisDexA, "A-chassis (DTL-H10000)"}, // A {&IsChassisDexA, "A-chassis (DTL-T10000H)"}, // A2 {&IsChassisDexA, "A-chassis (DTL-T10000)"}, // A3 {&IsChassisDexB, "B-chassis (DTL-H30001/2 with Auto-Tilt motor)"}, - {&IsChassisDexD, "D-chassis (DTL-H30000)"}, - {&IsChassisDragon, "Dragon (DTL-500xx--DTL-900xx)"}}; + {&IsChassisDexD, "D-chassis (DTL-H30x0x)"}, + {&IsChassisDragon, "Dragon (DTL-5x0xx--DTL-900xx)"}}; int SelectCount, LastSelectIndex, i, choice; DisplayCommonConsoleInfo(); - printf("Chassis:\n"); + PlatShowMessage("Chassis:\n"); for (i = 0, SelectCount = 0, LastSelectIndex = -1; i < MECHA_CHASSIS_MODEL_COUNT; i++) { if (data[i].probe() != 0) { - printf("\t%2d. %s\n", i + 1, data[i].label); + PlatShowMessage("\t%2d. %s\n", i + 1, data[i].label); SelectCount++; LastSelectIndex = i; } @@ -286,10 +286,10 @@ static int SelectChassis(void) if (SelectCount > 1) { - printf("\t%2d. None\n", i + 1); + PlatShowMessage("\t%2d. None\n", i + 1); do { - printf("Choice: "); + PlatShowMessage("Choice: "); choice = 0; if (scanf("%d", &choice) > 0) while (getchar() != '\n') @@ -325,11 +325,11 @@ void MenuEEPROM(void) "A-chassis (DTL-T10000H)", "A-chassis (DTL-T10000)", "B-chassis (DTL-H30001/2)", - "D-chassis (DTL-H30000)" + "D-chassis (DTL-H30000)", "H-chassis (DTL-H500xx)"}; unsigned char done; short int choice, chassis; - char filename[32]; + char filename[256]; done = 0; do @@ -340,11 +340,11 @@ void MenuEEPROM(void) return; } if (IsOutdatedBCModel()) - printf("B/C-chassis: EEPROM update required.\n"); + PlatShowMessage("B/C-chassis: EEPROM update required.\n"); chassis = SelectChassis(); do { - printf("\nSelected chassis: %s\n" + PlatShowMessage("\nSelected chassis: %s\n" "EEPROM operations:\n" "\t1. Display console information\n" "\t2. Dump EEPROM\n" @@ -377,93 +377,122 @@ void MenuEEPROM(void) { case 1: DisplayCommonConsoleInfo(); - printf("Press ENTER to continue\n"); + PlatShowMessage("Press ENTER to continue\n"); while (getchar() != '\n') { }; break; case 2: - printf("Enter dump filename: "); - if (fgets(filename, sizeof(filename), stdin)) + { + char useDefault; + char default_filename[256]; + u32 serial = 0; + u8 emcs = 0; + + if (EEPROMInitSerial() == 0) + EEPROMGetSerial(&serial, &emcs); + + const char *model = EEPROMGetModelName(); + + const struct MechaIdentRaw *RawData; + RawData = MechaGetRawIdent(); + + // Format the filename + snprintf(default_filename, sizeof(default_filename), "%s_%07u_%s_%#08x.bin", model, serial, RawData->cfd, RawData->cfc); + + PlatShowMessage("Default filename: %s\n", default_filename); + PlatShowMessage("Do you want to use the default filename? (Y/N): "); + + if (scanf(" %c", &useDefault) > 0) + while (getchar() != '\n') + { + }; + + if (useDefault == 'Y' || useDefault == 'y') + strcpy(filename, default_filename); + else { - filename[strlen(filename) - 1] = '\0'; - // gets(filename); - printf("Dump %s.\n", DumpEEPROM(filename) == 0 ? "completed" : "failed"); + PlatShowMessage("Enter dump filename: "); + if (fgets(filename, sizeof(filename), stdin)) + filename[strlen(filename) - 1] = '\0'; } - break; + + PlatShowMessage("Dump %s.\n", DumpEEPROM(filename) == 0 ? "completed" : "failed"); + } + break; case 3: - printf("Enter dump filename: "); + PlatShowMessage("Enter dump filename: "); if (fgets(filename, sizeof(filename), stdin)) { filename[strlen(filename) - 1] = '\0'; // gets(filename); - printf("Restore %s.\n", RestoreEEPROM(filename) == 0 ? "completed" : "failed"); + PlatShowMessage("Restore %s.\n", RestoreEEPROM(filename) == 0 ? "completed" : "failed"); } break; case 4: #ifdef ID_MANAGEMENT - printf("EEPROM erase %s.\n", EEPROMClear() == 0 ? "completed" : "failed"); + PlatShowMessage("EEPROM erase %s.\n", EEPROMClear() == 0 ? "completed" : "failed"); #else - printf("Function disabled.\n"); + PlatShowMessage("Function disabled.\n"); #endif break; case 5: #ifdef ID_MANAGEMENT - printf("Defaults (all) load: %s.\n", EEPROMDefaultAll() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (all) load: %s.\n", EEPROMDefaultAll() == 0 ? "completed" : "failed"); #else - printf("Function disabled.\n"); + PlatShowMessage("Function disabled.\n"); #endif break; case 6: - printf("Defaults (disc detect) load: %s.\n", EEPROMDefaultDiscDetect() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (disc detect) load: %s.\n", EEPROMDefaultDiscDetect() == 0 ? "completed" : "failed"); break; case 7: - printf("Defaults (servo) load: %s.\n", EEPROMDefaultServo() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (servo) load: %s.\n", EEPROMDefaultServo() == 0 ? "completed" : "failed"); break; case 8: - printf("Defaults (tilt) load: %s.\n", EEPROMDefaultTilt() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (tilt) load: %s.\n", EEPROMDefaultTilt() == 0 ? "completed" : "failed"); break; case 9: - printf("Defaults (tray) load: %s.\n", EEPROMDefaultTray() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (tray) load: %s.\n", EEPROMDefaultTray() == 0 ? "completed" : "failed"); break; case 10: - printf("Defaults (EEGS) load: %s.\n", EEPROMDefaultEEGS() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (EEGS) load: %s.\n", EEPROMDefaultEEGS() == 0 ? "completed" : "failed"); break; case 11: - printf("Defaults (OSD) load: %s.\n", EEPROMDefaultOSD() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (OSD) load: %s.\n", EEPROMDefaultOSD() == 0 ? "completed" : "failed"); break; case 12: - printf("Defaults (RTC) load: %s.\n", EEPROMDefaultRTC() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (RTC) load: %s.\n", EEPROMDefaultRTC() == 0 ? "completed" : "failed"); break; case 13: - printf("Defaults (DVD Player) load: %s.\n", EEPROMDefaultDVDVideo() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (DVD Player) load: %s.\n", EEPROMDefaultDVDVideo() == 0 ? "completed" : "failed"); break; case 14: #ifdef ID_MANAGEMENT - printf("Defaults (ID) load: %s.\n", EEPROMDefaultID() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (ID) load: %s.\n", EEPROMDefaultID() == 0 ? "completed" : "failed"); #else - printf("Function disabled.\n"); + PlatShowMessage("Function disabled.\n"); #endif break; case 15: #ifdef ID_MANAGEMENT - printf("Defaults (Model Name) load: %s.\n", EEPROMDefaultModelName() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (Model Name) load: %s.\n", EEPROMDefaultModelName() == 0 ? "completed" : "failed"); #else - printf("Function disabled.\n"); + PlatShowMessage("Function disabled.\n"); #endif break; case 16: - printf("Defaults (Sanyo OP) load: %s.\n", EEPROMDefaultSanyoOP() == 0 ? "completed" : "failed"); + PlatShowMessage("Defaults (Sanyo OP) load: %s.\n", EEPROMDefaultSanyoOP() == 0 ? "completed" : "failed"); break; case 17: - printf("EEPROM update: %s.\n", UpdateEEPROM(chassis) == 0 ? "completed" : "failed"); + PlatShowMessage("EEPROM update: %s.\n", UpdateEEPROM(chassis) == 0 ? "completed" : "failed"); break; case 18: done = 1; break; } - printf("\nIf the EEPROM was updated, please reboot the MECHACON\n" + PlatShowMessage("\nIf the EEPROM was updated, please reboot the MECHACON\n" "by leaving this menu before pressing the RESET button.\n"); } while (!done); } diff --git a/base/eeprom.c b/base/eeprom.c index 003b028..68d4eff 100644 --- a/base/eeprom.c +++ b/base/eeprom.c @@ -123,7 +123,7 @@ int EEPROMReadWord(unsigned short int word, u16 *data) int result; char args[5], buffer[16]; - sprintf(args, "%04x", word); + snprintf(args, 5, "%04x", word); if ((result = MechaCommandExecute(MECHA_CMD_EEPROM_READ, MECHA_TASK_NORMAL_TO, args, buffer, sizeof(buffer))) == 9) { *data = (u16)strtoul(buffer + 5, NULL, 16); @@ -143,7 +143,7 @@ int EEPROMWriteWord(unsigned short int word, u16 data) char args[9], buffer[16]; int result; - sprintf(args, "%04x%04x", word, data); + snprintf(args, 9, "%04x%04x", word, data); if ((result = MechaCommandExecute(MECHA_CMD_EEPROM_WRITE, MECHA_TASK_NORMAL_TO, args, buffer, sizeof(buffer))) == 9) { result = 0; @@ -503,16 +503,16 @@ int EEPROMInitSerial(void) ConEmcs = 0; if (ConMD == 40) { - sprintf(address, "%04x", EEPROM_MAP_SERIAL_NEW_0); + snprintf(address, 5, "%04x", EEPROM_MAP_SERIAL_NEW_0); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_SERIAL_0, MECHA_TASK_NORMAL_TO, "SERIAL READ"); - sprintf(address, "%04x", EEPROM_MAP_SERIAL_NEW_1); + snprintf(address, 5, "%04x", EEPROM_MAP_SERIAL_NEW_1); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_SERIAL_1, MECHA_TASK_NORMAL_TO, "SERIAL READ"); } else { - sprintf(address, "%04x", EEPROM_MAP_SERIAL_0); + snprintf(address, 5, "%04x", EEPROM_MAP_SERIAL_0); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_SERIAL_0, MECHA_TASK_NORMAL_TO, "SERIAL READ"); - sprintf(address, "%04x", EEPROM_MAP_SERIAL_1); + snprintf(address, 5, "%04x", EEPROM_MAP_SERIAL_1); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_SERIAL_1, MECHA_TASK_NORMAL_TO, "SERIAL READ"); } @@ -534,40 +534,40 @@ int EEPROMInitModelName(void) memset(ConModelName, 0, sizeof(ConModelName)); if (ConMD == 40) { - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_0); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_0); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_0, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_1); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_1); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_1, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_2); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_2); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_2, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_3); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_3); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_3, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_4); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_4); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_4, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_5); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_5); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_5, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_6); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_6); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_6, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_NEW_7); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_NEW_7); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_7, MECHA_TASK_NORMAL_TO, "M NAME READ"); } else { - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_0); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_0); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_0, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_1); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_1); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_1, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_2); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_2); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_2, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_3); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_3); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_3, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_4); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_4); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_4, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_5); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_5); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_5, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_6); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_6); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_6, MECHA_TASK_NORMAL_TO, "M NAME READ"); - sprintf(address, "%04x", EEPROM_MAP_MODEL_NAME_7); + snprintf(address, 5, "%04x", EEPROM_MAP_MODEL_NAME_7); MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id++, MECHA_CMD_TAG_EEPROM_MODEL_NAME_7, MECHA_TASK_NORMAL_TO, "M NAME READ"); } if ((result = MechaCommandExecuteList(NULL, &EEPROMRxHandler)) == 0) diff --git a/base/elect-main.c b/base/elect-main.c index 9672a68..b4ee952 100644 --- a/base/elect-main.c +++ b/base/elect-main.c @@ -16,7 +16,7 @@ static int ElectPromptT10K(void) char input; do { - printf("DTL-T10000 (YEDS-18)? [y,n] "); + PlatShowMessage("DTL-T10000 (YEDS-18)? [y,n] "); input = getchar(); while (getchar() != '\n') { @@ -39,7 +39,7 @@ void MenuELECT(void) do { - printf("\nElectric Circuit Adjustment\n" + PlatShowMessage("\nElectric Circuit Adjustment\n" "This tool allows you to re-calibrate the electric circuit of the CD/DVD drive.\n" "You need to do this if you:\n" "\t1. Change/remove the OPtical (OP) block\n" diff --git a/base/elect.c b/base/elect.c index d8beaa0..2ad5331 100644 --- a/base/elect.c +++ b/base/elect.c @@ -26,7 +26,8 @@ typedef struct ElectMechaTaskPrep const char *args; } ElectMechaTaskPrep_t; -static const ElectMechaTaskPrep_t AutoAdjACommands[] = { // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 +static const ElectMechaTaskPrep_t AutoAdjACommands[] = { + // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, @@ -35,7 +36,7 @@ static const ElectMechaTaskPrep_t AutoAdjACommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, {9, MECHA_CMD_TAG_ELECT_CD_TYPE, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, // Change to the 12cm YEDS-18 for DTL-T10000/H {10, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "CD AUTO ADJUSTMENT (STAGE 1)", "01"}, {11, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_2, "CD AUTO ADJUSTMENT (STAGE 2)", "01"}, @@ -48,9 +49,9 @@ static const ElectMechaTaskPrep_t AutoAdjACommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {17, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {18, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {19, MECHA_CMD_TAG_ELECT_DVDSL_DETECT_ADJ, 20000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, // If this command succeeds (byte 1 is not a '1'), disable the next 4 commands. + {19, MECHA_CMD_TAG_ELECT_DVDSL_DETECT_ADJ, 20000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, // If this command succeeds (byte 1 is not a '1'), disable the next 4 commands. {20, MECHA_CMD_TAG_ELECT_DVDSL_WR_WORK0_F0, 1000, MECHA_CMD_EEPROM_WRITE, "DVD-SL DETECT WR WORK0=F0", "000a00f0"}, - {21, 0, 20000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJ (DVD-DL)", "02"}, + {21, 0, 20000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJ (DVD-DL) TO EEPROM WR", "02"}, {22, MECHA_CMD_TAG_ELECT_DVDSL_RD_PULL_IN, 1000, MECHA_CMD_EEPROM_READ, "DVD-SL DETECT RD PULL-IN", "0001"}, // Value is acted on by ElectDiscDetectPullIn() {23, MECHA_CMD_TAG_ELECT_DVDSL_WR_WORK0_NEW, 1000, MECHA_CMD_EEPROM_WRITE, "DVD-SL DETECT WR WORK0=NEW", "000axxxx"}, // Use value from ElectDiscDetectPullIn() {24, 0, 1000, MECHA_CMD_DISC_MODE_DVDSL_12, "DISC MODE DVD-SL 12cm", NULL}, @@ -69,7 +70,7 @@ static const ElectMechaTaskPrep_t AutoAdjACommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-DL and press ENTER", NULL}, {37, 0, 6000, MECHA_CMD_TRAY, "DVD-DL TRAY CLOSE", "00"}, {38, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-DL SLED HOME POSITION", NULL}, - {39, 0, 20000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT ADJUSTMENT", "02"}, + {39, 0, 20000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT ADJUSTMENT TO EEPROM WR", "02"}, {40, MECHA_CMD_TAG_ELECT_DVDDL_DISC_DET_JUDGE, 20000, MECHA_CMD_DISC_DETECT, "DVD-DL DETECT JUDGEMENT", NULL}, {41, 0, 1000, MECHA_CMD_DISC_MODE_DVDDL_12, "DISC MODE DVD-DL 12cm", NULL}, {42, 0, 30000, MECHA_CMD_AUTO_ADJ_ST_1, "DVD-DL AUTO ADJUSTMENT (STAGE 1)", "01"}, @@ -91,9 +92,11 @@ static const ElectMechaTaskPrep_t AutoAdjACommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {57, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {58, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 +static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { + // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, @@ -102,7 +105,7 @@ static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, {9, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, {10, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "CD AUTO ADJUSTMENT (STAGE 1)", "01"}, {11, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_2, "CD AUTO ADJUSTMENT (STAGE 2)", "01"}, @@ -115,7 +118,7 @@ static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {17, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {18, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {19, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {19, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, {20, 0, 1000, MECHA_CMD_DISC_MODE_DVDSL_12, "DISC MODE DVD-SL 12cm", NULL}, {21, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "DVD-SL AUTO ADJUSTMENT (STAGE 1)", "01"}, {22, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_2, "DVD-SL AUTO ADJUSTMENT (STAGE 2)", "01"}, @@ -132,8 +135,8 @@ static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-DL and press ENTER", NULL}, {33, 0, 6000, MECHA_CMD_TRAY, "DVD-DL TRAY CLOSE", "00"}, {34, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-DL SLED HOME POSITION", NULL}, - {35, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT ADJUSTMENT", "02"}, - {36, 0, 5000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT EEPROM WRITE", "03"}, + {35, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT ADJUSTMENT TO EEPROM WR", "02"}, + {36, 0, 5000, MECHA_CMD_DETECT_ADJ, "DVD-DL DETECT EEPROM WRITE TO EEPROM WR", "03"}, {37, MECHA_CMD_TAG_ELECT_DVDDL_DISC_DET_JUDGE, 5000, MECHA_CMD_DISC_DETECT, "DVD-DL DETECT JUDGEMENT", NULL}, {38, 0, 1000, MECHA_CMD_DISC_MODE_DVDDL_12, "DISC MODE DVD-DL 12cm", NULL}, {39, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "DVD-DL AUTO ADJUSTMENT (STAGE 1)", "01"}, @@ -155,9 +158,11 @@ static const ElectMechaTaskPrep_t AutoAdj139Commands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {54, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {55, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdjFCommands[] = { // Test CD SCD-2700, DVD-SL HX-504, DVD-DL HX-505 +static const ElectMechaTaskPrep_t AutoAdjFCommands[] = { + // Test CD SCD-2700, DVD-SL HX-504, DVD-DL HX-505 {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, @@ -166,7 +171,7 @@ static const ElectMechaTaskPrep_t AutoAdjFCommands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, {9, MECHA_CMD_TAG_ELECT_OP_TYPE_ERROR, 6000, MECHA_CMD_EEPROM_READ, "CD GET CD-MIN (OP TYPE ERR)", "0002"}, {10, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, {11, 0, 20000, MECHA_CMD_AUTO_ADJ_FIX_GAIN, "CD AUTO ADJUSTMENT (FIX GAIN)", "0103"}, @@ -179,7 +184,7 @@ static const ElectMechaTaskPrep_t AutoAdjFCommands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {17, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {18, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {19, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {19, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, {20, MECHA_CMD_TAG_ELECT_DISC_DET_DVDMIN_RD, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM-DVDmin RD", "0004"}, {21, MECHA_CMD_TAG_ELECT_DISC_DET_CDMIN_WR, 5000, MECHA_CMD_EEPROM_WRITE, "DISC DETECT EEPROM-CDmin WR", "0002xxxx"}, {22, MECHA_CMD_TAG_ELECT_DISC_DET_DVDMAX_WR, 5000, MECHA_CMD_EEPROM_WRITE, "DISC DETECT EEPROM-DVDmax WR", "0005xxxx"}, @@ -221,9 +226,11 @@ static const ElectMechaTaskPrep_t AutoAdjFCommands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {57, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {58, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdjGCommands[] = { // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 +static const ElectMechaTaskPrep_t AutoAdjGCommands[] = { + // Test CD SCD-2700/YEDS-18, DVD-SL HX-504, DVD-DL HX-505 {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, @@ -232,7 +239,7 @@ static const ElectMechaTaskPrep_t AutoAdjGCommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, {9, MECHA_CMD_TAG_ELECT_OP_TYPE_ERROR, 6000, MECHA_CMD_EEPROM_READ, "CD GET CD-MAX (OP TYPE ERR)", "0003"}, {10, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, {11, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "CD AUTO ADJUSTMENT (STAGE 1)", "01"}, @@ -246,7 +253,7 @@ static const ElectMechaTaskPrep_t AutoAdjGCommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {18, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {19, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {20, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {20, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, {21, 0, 5000, MECHA_CMD_DETECT_ADJ, "DISC DETECT EEPROM WR", "03"}, {22, 0, 5000, MECHA_CMD_UPLOAD_TO_RAM, "COPY EEPROM DATA TO MECHACON", "02"}, {23, MECHA_CMD_TAG_ELECT_DISC_DET_DVDMIN_RD, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM-DVDmin RD", "0004"}, @@ -294,9 +301,11 @@ static const ElectMechaTaskPrep_t AutoAdjGCommands[] = { // Test CD SCD-2700/ {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {64, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {65, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdjG2Commands[] = { // Test CD SCD-2700, DVD-SL HX-504, DVD-DL HX-505 +static const ElectMechaTaskPrep_t AutoAdjG2Commands[] = { + // Test CD SCD-2700, DVD-SL HX-504, DVD-DL HX-505 {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, @@ -305,7 +314,7 @@ static const ElectMechaTaskPrep_t AutoAdjG2Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 6000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, {9, MECHA_CMD_TAG_ELECT_OP_TYPE_ERROR, 6000, MECHA_CMD_EEPROM_READ, "CD GET CD-MAX (OP TYPE ERR)", "0003"}, {10, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, {11, 0, 20000, MECHA_CMD_AUTO_ADJ_ST_1, "CD AUTO ADJUSTMENT (STAGE 1)", "01"}, @@ -321,7 +330,7 @@ static const ElectMechaTaskPrep_t AutoAdjG2Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {20, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {21, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {22, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {22, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, {23, 0, 5000, MECHA_CMD_DETECT_ADJ, "DISC DETECT EEPROM WR", "03"}, {24, MECHA_CMD_TAG_ELECT_DISC_DET_DVDMIN_RD, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM-DVDmin RD", "0004"}, {25, MECHA_CMD_TAG_ELECT_DVDSL_DISC_DET_JUDGE, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM-CDmax RD", "0003"}, @@ -372,9 +381,11 @@ static const ElectMechaTaskPrep_t AutoAdjG2Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {68, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {69, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { // Test CD SCD-2700, DVD-SL TDV-520CSC, DVD-DL TDV-540CSC +static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { + // Test CD SCD-2700, DVD-SL TDV-520CSC, DVD-DL TDV-540CSC {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {0, 0, 1000, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 1s", NULL}, @@ -384,7 +395,9 @@ static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test CD and press ENTER", NULL}, {6, 0, 6000, MECHA_CMD_TRAY, "CD TRAY CLOSE", "00"}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, {10, MECHA_CMD_TAG_ELECT_OP_TYPE_ERROR, 6000, MECHA_CMD_EEPROM_READ, "CD GET CD-MAX (OP TYPE ERR)", "0034"}, {11, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, @@ -404,9 +417,13 @@ static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Insert test DVD-SL and press ENTER", NULL}, {23, 0, 6000, MECHA_CMD_TRAY, "DVD-SL TRAY CLOSE", "00"}, {24, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {25, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {25, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, {26, 0, 5000, MECHA_CMD_DETECT_ADJ, "DISC DETECT DATA TO EEPROM WR", "03"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, {27, MECHA_CMD_TAG_ELECT_DISC_DET_DVDMIN_RD, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM RD", "0035"}, {28, MECHA_CMD_TAG_ELECT_DVDSL_DISC_DET_JUDGE, 5000, MECHA_CMD_EEPROM_READ, "DISC DETECT EEPROM RD", "0034"}, @@ -428,7 +445,11 @@ static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { // Test CD SCD-2700, {0, 0, 1000, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 1s", NULL}, {43, MECHA_CMD_TAG_ELECT_DVDSL_MIRR, 3000, MECHA_CMD_MIRR_CHECK, "DVD-SL MIRR CHECK", NULL}, {44, MECHA_CMD_TAG_ELECT_DVDSL_MIRR_EEPROM_WR, 6000, MECHA_CMD_EEPROM_WRITE, "DVD-SL EEPROM WR 0x01E-3019", "001e3019"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {45, MECHA_CMD_TAG_ELECT_DVDSL_MIRR_EEPROM_WR, 6000, MECHA_CMD_EEPROM_WRITE, "DVD-SL EEPROM WR 0x01F-3039", "001f3039"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {46, MECHA_CMD_TAG_ELECT_DVDSL_FOCUS_OFFSET, 6000, MECHA_CMD_FE_OFFSET, "DVD-SL FE OFFSET CHECK", "0500"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "DVD-SL FE DE-FOCUS CHECK WAIT 100ms", NULL}, {47, MECHA_CMD_TAG_ELECT_DVDSL_DEFOCUS_OFFSET, 6000, MECHA_CMD_EEPROM_READ, "DVD-SL FE DE-FOCUS CHECK", "004c"}, @@ -466,16 +487,20 @@ static const ElectMechaTaskPrep_t AutoAdj140Commands[] = { // Test CD SCD-2700, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Remove disc and press ENTER", NULL}, {76, 0, 6000, MECHA_CMD_TRAY, "TRAY CLOSE", "00"}, {77, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; -static const ElectMechaTaskPrep_t AutoAdjSlimCommands[] = { // Test CD SCD-2700, DVD-SL TDV-520CSC, DVD-DL TDV-540CSC +static const ElectMechaTaskPrep_t AutoAdjSlimCommands[] = { + // Test CD SCD-2700, DVD-SL TDV-520CSC, DVD-DL TDV-540CSC {1, 0, 1000, MECHA_CMD_DISC_MODE_CD_12, "DISC MODE CD 12cm", NULL}, {2, 0, 3000, MECHA_CMD_FOCUS_UPDOWN, "FOCUS UP/DOWN END", "00"}, {0, 0, 1000, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 1s", NULL}, {3, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Open lid, insert test CD, close lid and press ENTER", NULL}, {7, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, - {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT", "00"}, + {8, 0, 15000, MECHA_CMD_DETECT_ADJ, "CD DETECT ADJUSTMENT TO EEPROM WR", "00"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, {10, MECHA_CMD_TAG_ELECT_OP_TYPE_ERROR, 6000, MECHA_CMD_EEPROM_READ, "CD GET CD-MAX (OP TYPE ERR)", "0034"}, {11, 0, 1000, MECHA_CMD_DISC_MODE_CD_8, "CD 8cm DISC MODE", NULL}, @@ -493,7 +518,9 @@ static const ElectMechaTaskPrep_t AutoAdjSlimCommands[] = { // Test CD SCD-2700, {21, 0, 3000, MECHA_CMD_SLED_POS_HOME, "CD SLED HOME POSITION", NULL}, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Open lid, insert test DVD-SL, close lid and press ENTER", NULL}, {24, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-SL SLED HOME POSITION", NULL}, - {25, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT", "01"}, + {25, 0, 10000, MECHA_CMD_DETECT_ADJ, "DVD-SL DETECT ADJUSTMENT TO EEPROM WR", "01"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, {26, 0, 5000, MECHA_CMD_DETECT_ADJ, "DISC DETECT DATA TO EEPROM WR", "03"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 100ms", NULL}, @@ -517,7 +544,11 @@ static const ElectMechaTaskPrep_t AutoAdjSlimCommands[] = { // Test CD SCD-2700, {0, 0, 1000, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 1s", NULL}, {43, MECHA_CMD_TAG_ELECT_DVDSL_MIRR, 3000, MECHA_CMD_MIRR_CHECK, "DVD-SL MIRR CHECK", NULL}, {44, MECHA_CMD_TAG_ELECT_DVDSL_MIRR_EEPROM_WR, 6000, MECHA_CMD_EEPROM_WRITE, "DVD-SL EEPROM WR 0x01E-3019", "001e3019"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {45, MECHA_CMD_TAG_ELECT_DVDSL_MIRR_EEPROM_WR, 6000, MECHA_CMD_EEPROM_WRITE, "DVD-SL EEPROM WR 0x01F-3039", "001f3039"}, + {0, 0, 500, MECHA_TASK_UI_CMD_WAIT, "CD WAIT 500ms", NULL}, + {0, 0, 3000, MECHA_CMD_WRITE_CHECKSUM, "ALL EEPROM CHECK SUM WR", "00"}, {46, MECHA_CMD_TAG_ELECT_DVDSL_FOCUS_OFFSET, 6000, MECHA_CMD_FE_OFFSET, "DVD-SL FE OFFSET CHECK", "0500"}, {0, 0, 100, MECHA_TASK_UI_CMD_WAIT, "DVD-SL FE DE-FOCUS CHECK WAIT 100ms", NULL}, {47, MECHA_CMD_TAG_ELECT_DVDSL_DEFOCUS_OFFSET, 6000, MECHA_CMD_EEPROM_READ, "DVD-SL FE DE-FOCUS CHECK", "004c"}, @@ -551,7 +582,8 @@ static const ElectMechaTaskPrep_t AutoAdjSlimCommands[] = { // Test CD SCD-2700, {74, 0, 3000, MECHA_CMD_SLED_POS_HOME, "DVD-DL SLED HOME POSITION", NULL}, {0, 0, 0, MECHA_TASK_UI_CMD_MSG, "Open lid, remove disc, close lid and press ENTER", NULL}, {77, 0, 3000, MECHA_CMD_SLED_POS_HOME, "FIN (SLED HOME)", NULL}, - {-1, -1, -1, -1, NULL, NULL}}; + {0, 0, 0, 0, NULL, NULL}, +}; static int ElectJudgeOPTypeError(const char *result, int len) { @@ -672,7 +704,7 @@ static int ElectJudgeCDTELoopGain(const char *result, int len) else { PlatShowEMessage("CD TE LOOP GAIN NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -774,7 +806,7 @@ static int ElectJudgeDVDSLFELoopGain(const char *result, int len) else { PlatShowEMessage("DVD-SL FE LOOP GAIN NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -791,7 +823,7 @@ static int ElectJudgeDVDSLTELoopGain(const char *result, int len) else { PlatShowEMessage("DVD-SL TE LOOP GAIN NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -821,7 +853,7 @@ static int ElectJudgeDVDSLJitter256(const char *result, int len) else { PlatShowEMessage("DVD-SL jitter(256) NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -906,7 +938,7 @@ static int ElectJudgeDVDDLL0TELoopGain(const char *result, int len) else { PlatShowEMessage("DVD-DL-L0 TE LOOP GAIN NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -936,7 +968,7 @@ static int ElectJudgeDVDDLL0Jitter256(const char *result, int len) else { PlatShowEMessage("DVD-DL-L0 jitter(256) NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -970,7 +1002,7 @@ static int ElectJudgeDVDDLL1TELoopGain(const char *result, int len) else { PlatShowEMessage("DVD-DL-L1 TE LOOP GAIN NG: %d\n", value); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1168,7 +1200,7 @@ static int ElectJudgeCDRFDCLevel(const char *data, int len) else { PlatShowEMessage("CD RFDC level NG: %d\n", result); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1192,7 +1224,7 @@ static int ElectJudgeDVDSLRFDCLevel(const char *data, int len) else { PlatShowEMessage("DVD-SL RFDC level NG: %d\n", result); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1216,7 +1248,7 @@ static int ElectJudgeDVDDLL0RFDCLevel(const char *data, int len) else { PlatShowEMessage("DVD-DL-L0 RFDC level NG: %d\n", result); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1240,7 +1272,7 @@ static int ElectJudgeDVDDLL1RFDCLevel(const char *data, int len) else { PlatShowEMessage("DVD-DL-L1 RFDC level NG: %d\n, result"); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1250,13 +1282,21 @@ static int ElectJudgeCDTPP(const char *data, int len) unsigned short int value1, value2, value3; int sub32, Tbal; + // example data 0995F7D + // Extract the first two characters from the data (99) strncpy(number, &data[1], 2); number[2] = '\0'; value1 = (unsigned short int)strtoul(number, NULL, 16); + + // Extract the next two characters from the data (5F) strncpy(number, &data[3], 2); number[2] = '\0'; value2 = (unsigned short int)strtoul(number, NULL, 16); + + // Extract the last two characters from the data (7D) value3 = (unsigned short int)strtoul(&data[5], NULL, 16); + + // Subtract value2 from value1 (3A) value1 -= value2; if (value1 >= 0x35 && value1 <= 0x7E) // TPP check @@ -1274,13 +1314,13 @@ static int ElectJudgeCDTPP(const char *data, int len) else { PlatShowEMessage("CD TPP Tbal NG: %ld\n", Tbal); - return 1; + return (ConSlim == 1) ? 0 : 1; } } else { PlatShowEMessage("CD TPP NG: %d\n", value1); - return 1; + return (ConSlim == 1) ? 0 : 1; } } @@ -1335,9 +1375,9 @@ static int JudgeDVDSLDeFocusOffset(const char *data, int len) offset = (unsigned int)strtoul(&data[5], NULL, 16); if (offset == 0x100) - offset = -(~offset & 0xFF); + offset = -((int)((~offset) & 0xFF)); else - offset &= 0xFF; + offset = (int)(offset & 0xFF); result = offset / (ConFocusOffset << 2) * 100.0f; @@ -1414,13 +1454,13 @@ static int ElectTxHandler(MechaTask_t *task) } return 0; case MECHA_CMD_TAG_ELECT_DVDSL_WR_WORK0_NEW: - sprintf(&task->args[4], "%04x", DiscDetectValue136); + snprintf(&task->args[4], 5, "%04x", DiscDetectValue136); return 0; case MECHA_CMD_TAG_ELECT_DISC_DET_CDMIN_WR: - sprintf(&task->args[4], "%04x", CDminCalc); + snprintf(&task->args[4], 5, "%04x", CDminCalc); return 0; case MECHA_CMD_TAG_ELECT_DISC_DET_DVDMAX_WR: - sprintf(&task->args[4], "%04x", DVDmaxCalc); + snprintf(&task->args[4], 5, "%04x", DVDmaxCalc); return 0; case MECHA_CMD_TAG_ELECT_DVDSL_MIRR_EEPROM_WR: if (DisableEEPMIRRWrite) diff --git a/base/id-main.c b/base/id-main.c new file mode 100644 index 0000000..6f927d0 --- /dev/null +++ b/base/id-main.c @@ -0,0 +1,327 @@ +#include +#include +#include +#include + +#include "platform.h" +#include "mecha.h" +#include "eeprom.h" +#include "eeprom-id.h" +#include "main.h" + +extern unsigned char ConType; + +static void InitMechacon(void) +{ + int choice, done, dex, NumChoices; + + if (ConType == MECHA_TYPE_40) + { + done = 0; + while (!done) + { + do + { + PlatShowMessage("MECHACON initialization for H/I-chassis\n" + "Select type:\n" + "\t1. CEX\n" + "\t2. DEX\n" + "\t3. Quit\n" + "Your choice: "); + choice = 0; + if (scanf("%d", &choice) > 0) + while (getchar() != '\n') + { + }; + } while (choice < 1 || choice > 3); + + switch (choice) + { + case 1: + dex = 0; + break; + case 2: + dex = 1; + break; + case 3: + done = 1; + } + + if (!done) + { + do + { + if (!dex) + { + PlatShowMessage("Select model Name:\n" + "\t1. SCPH-xx000 (Japan)\n" + "\t2. SCPH-xx001 (USA)\n" + "\t3. SCPH-xx002 (Australia)\n" + "\t4. SCPH-xx003 (Great Britian)\n" + "\t5. SCPH-xx004 (Europe)\n" + "\t6. SCPH-xx005 (Korea)\n" + "\t7. SCPH-xx006 (Hong Kong)\n" + "\t8. SCPH-xx007 (Taiwan)\n" + "\t9. SCPH-xx008 (Russia)\n" + "\t10. SCPH-50009 (China)\n" + "\t11. SCPH-xx010 (SCPH-50010: Canada, Slims: Mexico)\n" + "\t12. SCPH-x0011 (SCPH-50011: Mexico, SCPH-70011: USA)\n" + "\t13. SCPH-70012 (Canada)\n" + "\t14. Quit\n" + "Your choice: "); + NumChoices = 12; + } + else + { + PlatShowMessage("Select model Name:\n" + "\t1. DTL-H50000\n" + "\t2. DTL-H50001\n" + "\t3. DTL-H50002\n" + "\t4. DTL-H50005\n" + "\t5. DTL-H50006\n" + "\t6. DTL-H50008\n" + "\t7. DTL-H50009\n" + "\t8. Quit\n" + "Your choice: "); + NumChoices = 8; + } + choice = 0; + if (scanf("%d", &choice) > 0) + while (getchar() != '\n') + { + }; + } while (choice < 1 || choice > NumChoices); + if (!dex) + { + switch (choice) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + PlatShowMessage("MechaInit: %s\n", MechaInitMechacon(choice, 0) == 0 ? "done" : "failed"); + break; + case 14: + done = 1; + } + } + else + { + switch (choice) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + PlatShowMessage("MechaInit: %s\n", MechaInitMechacon(choice, 1) == 0 ? "done" : "failed"); + break; + case 8: + done = 1; + } + } + } + } + } + else + PlatShowMessage("MechaInit: Unsupported chassis.\n"); +} + +static void WriteiLinkID(void) +{ + u8 iLinkID[8]; + unsigned char i; + unsigned short int NewiLinkIDInput[8]; + + EEPROMGetiLinkID(iLinkID); + PlatShowMessage("Current i.Link ID:\t%02x %02x %02x %02x %02x %02x %02x %02x\n" + "Enter new ID:\t\t", + iLinkID[0], iLinkID[1], iLinkID[2], iLinkID[3], iLinkID[4], iLinkID[5], iLinkID[6], iLinkID[7]); + if (scanf("%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx", + &NewiLinkIDInput[0], &NewiLinkIDInput[1], &NewiLinkIDInput[2], &NewiLinkIDInput[3], &NewiLinkIDInput[4], + &NewiLinkIDInput[5], &NewiLinkIDInput[6], &NewiLinkIDInput[7]) == 8) + { + for (i = 0; i < 8; i++) + iLinkID[i] = (u8)NewiLinkIDInput[i]; + PlatShowMessage("iLink ID update %s\n", (EEPROMSetiLinkID(iLinkID) == 0) ? "completed" : "failed"); + } + else + { + PlatShowMessage("Operation aborted.\n"); + } + + while (getchar() != '\n') + { + }; +} + +static void WriteConsoleID(void) +{ + u8 ConsoleID[8]; + unsigned char i; + unsigned short int NewConsoleIDInput[8]; + + EEPROMGetConsoleID(ConsoleID); + PlatShowMessage("Current console ID:\t%02x %02x %02x %02x %02x %02x %02x %02x\n" + "Enter new ID:\t\t", + ConsoleID[0], ConsoleID[1], ConsoleID[2], ConsoleID[3], ConsoleID[4], ConsoleID[5], ConsoleID[6], ConsoleID[7]); + if (scanf("%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx", + &NewConsoleIDInput[0], &NewConsoleIDInput[1], &NewConsoleIDInput[2], &NewConsoleIDInput[3], &NewConsoleIDInput[4], + &NewConsoleIDInput[5], &NewConsoleIDInput[6], &NewConsoleIDInput[7]) == 8) + { + for (i = 0; i < 8; i++) + ConsoleID[i] = (u8)NewConsoleIDInput[i]; + PlatShowMessage("Console ID update %s\n", (EEPROMSetConsoleID(ConsoleID) == 0) ? "completed" : "failed"); + } + else + { + PlatShowMessage("Operation aborted.\n"); + } + + while (getchar() != '\n') + { + }; +} + +static void WriteModelName(void) +{ + const char *ModelName; + char NewModelName[32]; // Maximum of 16 characters for the model name. Anything longer will be truncated. + + switch (ConType) + { + case MECHA_TYPE_36: + PlatShowMessage("This model does not support a model name.\n"); + return; + } + + ModelName = EEPROMGetModelName(); + PlatShowMessage("Current model name:\t%s\n" + "Maximum length is 16\n" + "Enter new name:\t\t", + ModelName[0] == 0x00 ? "" : ModelName); + if (fgets(NewModelName, sizeof(NewModelName), stdin)) + { + NewModelName[16] = '\0'; + PlatShowMessage("Model name update %s\n", (EEPROMSetModelName(NewModelName) == 0) ? "completed" : "failed"); + } +} + +static void DisplayIDInfo(void) +{ + u8 iLinkID[8], ConsoleID[8]; + + EEPROMGetiLinkID(iLinkID); + EEPROMGetConsoleID(ConsoleID); + PlatShowMessage("i.Link ID:\t%02x %02x %02x %02x %02x %02x %02x %02x\n" + "Console ID:\t%02x %02x %02x %02x %02x %02x %02x %02x\n", + iLinkID[0], iLinkID[1], iLinkID[2], iLinkID[3], iLinkID[4], iLinkID[5], iLinkID[6], iLinkID[7], + ConsoleID[0], ConsoleID[1], ConsoleID[2], ConsoleID[3], ConsoleID[4], ConsoleID[5], ConsoleID[6], ConsoleID[7]); +} + +static void InitNTSCPALDefaults(void) +{ + int choice; + + do + { + PlatShowMessage("NTSC/PAL selection:\n" + "\t1. NTSC\n" + "\t2. PAL\n" + "\t3. Quit\n" + "Your choice: "); + choice = 0; + if (scanf("%d", &choice) > 0) + while (getchar() != '\n') + { + }; + } while (choice < 1 || choice > 3); + + switch (choice) + { + case 1: + PlatShowMessage("Init NTSC defaults: %s\n", EEPROMNTSCPALDefaults(0) == 0 ? "completed" : "failed"); + break; + case 2: + PlatShowMessage("Init PAL defaults: %s\n", EEPROMNTSCPALDefaults(1) == 0 ? "completed" : "failed"); + break; + } +} + +void MenuID(void) +{ + char done; + int choice; + + if (MechaInitModel() != 0 || EEPROMInitID() != 0) + { + DisplayConnHelp(); + return; + } + + done = 0; + do + { + do + { + DisplayCommonConsoleInfo(); + DisplayIDInfo(); + PlatShowMessage("ID Managenent:\n" + "\t1. Write i.Link ID\n" + "\t2. Write console ID\n" + "\t3. Write model name (AB-chassis and later only)\n" + "\t4. Initialize NTSC/PAL defaults (B-chassis DEX and later only)\n" + "\t5. Initialize MECHACON (H/I-chassis only)\n" + "\t6. Quit\n" + "Your choice: "); + choice = 0; + if (scanf("%d", &choice) > 0) + while (getchar() != '\n') + { + }; + } while (choice < 1 || choice > 6); + putchar('\n'); + + switch (choice) + { + case 1: + WriteiLinkID(); + if (EEPROMInitID() != 0) + { + DisplayConnHelp(); + return; + } + break; + case 2: + WriteConsoleID(); + if (EEPROMInitID() != 0) + { + DisplayConnHelp(); + return; + } + break; + case 3: + WriteModelName(); + break; + case 4: + InitNTSCPALDefaults(); + break; + case 5: + InitMechacon(); + break; + default: + done = 1; + } + } while (!done); +} diff --git a/PMAP/main.c b/base/main.c similarity index 76% rename from PMAP/main.c rename to base/main.c index 5516d7e..6788e2a 100644 --- a/PMAP/main.c +++ b/base/main.c @@ -5,9 +5,9 @@ #include #include "platform.h" -#include "../base/main.h" -#include "../base/mecha.h" -#include "../base/eeprom.h" +#include "main.h" +#include "mecha.h" +#include "eeprom.h" void DisplayRawIdentData(void) { @@ -17,7 +17,7 @@ void DisplayRawIdentData(void) MechaGetMode(&tm, &md); RawData = MechaGetRawIdent(); - printf("\nTestMode.%d MD1.%d\n" + PlatShowMessage("\nTestMode.%d MD1.%d\n" "CFD:\t\t0x%s\n" "CFC:\t\t%#08x\n" "Version:\t%#04x\n", @@ -31,40 +31,40 @@ void DisplayCommonConsoleInfo(void) u8 emcs, tm, md; MechaGetMode(&tm, &md); - printf("\nTestMode.%d MD1.%d\tChecksum: %s\n" + PlatShowMessage("\nTestMode.%d MD1.%d\tChecksum: %s\n" "MECHA:\t\t%s (%s)\n", tm, md, MechaGetEEPROMStat() ? "OK" : "NG", MechaGetDesc(), MechaGetCEXDEX() == 0 ? "DEX" : "CEX"); - printf("Serial:\t\t"); + PlatShowMessage("Serial:\t\t"); if (EEPROMInitSerial() == 0) { EEPROMGetSerial(&serial, &emcs); - printf("%07u\t\t" + PlatShowMessage("%07u\t\t" "EMCS:\t%02x\n", serial, emcs); } else - printf("\n"); - printf("MODELID:\t%04x\t\tTV:\t%s\n", EEPROMGetModelID(), MechaGetTVSystemDesc(EEPROMGetTVSystem())); - printf("Model:\t\t"); + PlatShowMessage("\n"); + PlatShowMessage("MODELID:\t%04x\t\tTV:\t%s\n", EEPROMGetModelID(), MechaGetTVSystemDesc(EEPROMGetTVSystem())); + PlatShowMessage("Model:\t\t"); if (EEPROMInitModelName() == 0) { ModelName = EEPROMGetModelName(); - printf("%s\n", ModelName); + PlatShowMessage("%s\n", ModelName); } else - printf("\n"); - printf("RTC:\t\t%s (%s)\n" + PlatShowMessage("\n"); + PlatShowMessage("RTC:\t\t%s (%s)\n" "OP:\t\t%s\t\tLens:\t%s\n", MechaGetRTCName(MechaGetRTCType()), MechaGetRtcStatusDesc(MechaGetRTCType(), MechaGetRTCStat()), MechaGetOPTypeName(MechaGetOP()), MechaGetLensTypeName(MechaGetLens())); if (EEPROMGetEEPROMStatus() == 1) - printf("EEPROM was erased (defaults must now be loaded).\n"); + PlatShowMessage("EEPROM was erased (defaults must now be loaded).\n"); } void DisplayConnHelp(void) { - printf("There was a problem communicating with the PlayStation 2 console.\n" + PlatShowMessage("There was a problem communicating with the PlayStation 2 console.\n" "Check the connections, press the RESET button and try again.\n\n"); } @@ -75,13 +75,13 @@ int main(int argc, char *argv[]) if (argc != 2) { - printf("Syntax error. Syntax: PMAP \n"); + PlatShowMessage("Syntax error. Syntax: PMAP \n"); return EINVAL; } if (PlatOpenCOMPort(argv[1]) != 0) { - printf("Cannot open %s.\n", argv[1]); + PlatShowMessage("Cannot open %s.\n", argv[1]); return ENODEV; } @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) { do { - printf("\nP.M.A.P (v1.2)\n" + PlatShowMessage("\nP.M.A.P (v1.2)\n" "=============================\n" "\t1.\tEEPROM management\n" "\t2.\tAutomatic ELECT adjustment\n" diff --git a/base/mecha-main.c b/base/mecha-main.c index 0dba8d2..039b097 100644 --- a/base/mecha-main.c +++ b/base/mecha-main.c @@ -120,29 +120,29 @@ static int MechaAdjTxHandler(MechaTask_t *task) switch (DiscDetect) { case DISC_TYPE_CD12: - printf("Disc type CD 12cm\n"); + PlatShowMessage("Disc type CD 12cm\n"); task->command = MECHA_CMD_DISC_MODE_CD_12; status = MECHA_ADJ_STATE_CD; return 0; case DISC_TYPE_DVDS12: - printf("Disc type DVD-SL 12cm\n"); + PlatShowMessage("Disc type DVD-SL 12cm\n"); task->command = MECHA_CMD_DISC_MODE_DVDSL_12; status = MECHA_ADJ_STATE_DVDSL; return 0; case DISC_TYPE_DVDD12: - printf("Disc type DVD-DL 12cm\n"); + PlatShowMessage("Disc type DVD-DL 12cm\n"); task->command = MECHA_CMD_DISC_MODE_DVDDL_12; status = MECHA_ADJ_STATE_DVDDL; return 0; case DISC_TYPE_UNKNOWN: - printf("Disc type unknown.\n"); + PlatShowMessage("Disc type unknown.\n"); task->id = 0; task->tag = 0; task->command = 0; status = MECHA_ADJ_STATE_NONE; return 0; case DISC_TYPE_NO_DISC: - printf("No disc inserted.\n"); + PlatShowMessage("No disc inserted.\n"); task->id = 0; task->tag = 0; task->command = 0; @@ -150,7 +150,7 @@ static int MechaAdjTxHandler(MechaTask_t *task) return 0; default: status = MECHA_ADJ_STATE_NONE; - printf("Unsupported disc type: %02x\n", DiscDetect); + PlatShowMessage("Unsupported disc type: %02x\n", DiscDetect); return 1; } default: @@ -386,7 +386,7 @@ static int MechaAdjInit(short int argc, char *argv[]) case MECHA_TYPE_40: break; default: - printf("MechaAdjInit: Unsupported chassis.\n"); + PlatShowMessage("MechaAdjInit: Unsupported chassis.\n"); return 0; } @@ -409,7 +409,7 @@ static int MechaAdjInit(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1: case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: - printf("Please STOP the drive first! Currently in another PLAY mode.\n"); + PlatShowMessage("Please STOP the drive first! Currently in another PLAY mode.\n"); return 0; } @@ -436,7 +436,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "CD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("CD initialization failed.\n"); + PlatShowMessage("CD initialization failed.\n"); else status = MECHA_ADJ_STATE_CD; @@ -463,7 +463,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-SL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-SL initialization failed.\n"); + PlatShowMessage("DVD-SL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDSL; @@ -489,7 +489,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-DL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-DL initialization failed.\n"); + PlatShowMessage("DVD-DL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDDL; @@ -516,7 +516,7 @@ static int MechaAdjInit(short int argc, char *argv[]) } MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "DVD-SL STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("DVD-SL initialization failed.\n"); + PlatShowMessage("DVD-SL initialization failed.\n"); else status = MECHA_ADJ_STATE_DVDSL; @@ -542,7 +542,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) switch (status) { case MECHA_ADJ_STATE_NONE: - printf("Please do initialization first!\n"); + PlatShowMessage("Please do initialization first!\n"); break; case MECHA_ADJ_STATE_DVDDL_PAUSE: case MECHA_ADJ_STATE_DVDDL_1: @@ -551,7 +551,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (!pstricmp(argv[1], "FJ")) { if ((result = MechaCommandExecute(MECHA_CMD_FOCUS_JUMP, 2000, "0300", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); break; } case MECHA_ADJ_STATE_DVDSL_PAUSE: @@ -564,7 +564,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_4: case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: - printf("Please STOP the drive. It is currently in PLAY mode.\n"); + PlatShowMessage("Please STOP the drive. It is currently in PLAY mode.\n"); break; case MECHA_ADJ_STATE_CD: speed = (int)strtol(argv[1], NULL, 0); @@ -592,7 +592,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) command = MECHA_CMD_CD_PLAY_5; break; default: - printf("Unsupported speed.\n"); + PlatShowMessage("Unsupported speed.\n"); timeout = 0; command = 0; } @@ -600,7 +600,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (command != 0) { if ((result = MechaCommandExecute(command, timeout, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else status += speed; @@ -626,7 +626,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) command = MECHA_CMD_DVD_PLAY_3; break; default: - printf("Unsupported speed.\n"); + PlatShowMessage("Unsupported speed.\n"); timeout = 0; command = 0; } @@ -634,7 +634,7 @@ static int MechaAdjPlay(short int argc, char *argv[]) if (command != 0) { if ((result = MechaCommandExecute(command, timeout, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else status += speed; @@ -663,7 +663,7 @@ static int MechaAdjStop(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: if ((result = MechaCommandExecute(MECHA_CMD_CD_STOP, 4000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); status = MECHA_ADJ_STATE_CD; break; case MECHA_ADJ_STATE_DVDSL_PAUSE: @@ -675,7 +675,7 @@ static int MechaAdjStop(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: if ((result = MechaCommandExecute(MECHA_CMD_DVD_STOP, 5000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); switch (status) { @@ -694,7 +694,7 @@ static int MechaAdjStop(short int argc, char *argv[]) } break; default: - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } return 0; @@ -706,7 +706,7 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) if (!IsAutoTiltModel()) { - printf("This is not a B-chassis (non-auto-tilt motor model).\n"); + PlatShowMessage("This is not a B-chassis (non-auto-tilt motor model).\n"); return 0; } @@ -717,13 +717,13 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_INIT_AUTO_TILT, NULL, id++, 0, 5000, "AUTO TILT INIT"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "ADJ")) { MechaCommandAdd(MECHA_CMD_ADJ_AUTO_TILT, "00", id++, 0, 15000, "TILT ADJUST"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "WRITE")) { @@ -739,19 +739,19 @@ static int MechaAdjAutoTilt(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_WRITE_CHECKSUM, "00", id++, 0, 3000, "EEPROM WRITE CHECKSUM"); MechaCommandAdd(MECHA_CMD_READ_CHECKSUM, "00", id++, 0, 3000, "EEPROM READ CHECKSUM"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "REV")) { MechaCommandAdd(MECHA_CMD_MOV_AUTO_TILT, "000001", id++, 0, 5000, "TILT ADJUST REV"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "FWD")) { MechaCommandAdd(MECHA_CMD_MOV_AUTO_TILT, "010001", id++, 0, 5000, "TILT ADJUST FWD"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -772,7 +772,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_PAUSE: case MECHA_ADJ_STATE_DVDSL_PAUSE: case MECHA_ADJ_STATE_DVDDL_PAUSE: - printf("Already paused.\n"); + PlatShowMessage("Already paused.\n"); break; case MECHA_ADJ_STATE_CD_1: case MECHA_ADJ_STATE_CD_2: @@ -780,7 +780,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_CD_512: case MECHA_ADJ_STATE_CD_1024: if ((result = MechaCommandExecute(MECHA_CMD_CD_PAUSE, 3000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); break; case MECHA_ADJ_STATE_DVDSL_1: case MECHA_ADJ_STATE_DVDSL_1p6: @@ -789,7 +789,7 @@ static int MechaAdjPause(short int argc, char *argv[]) case MECHA_ADJ_STATE_DVDDL_1p6: case MECHA_ADJ_STATE_DVDDL_1p64: if ((result = MechaCommandExecute(MECHA_CMD_DVD_PAUSE, 5000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); switch (status) { @@ -806,7 +806,7 @@ static int MechaAdjPause(short int argc, char *argv[]) } break; default: - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } return 0; @@ -823,37 +823,37 @@ static int MechaAdjTray(short int argc, char *argv[]) { if (!SledIsAtHome) { - printf("Sled must be in home position!\n"); + PlatShowMessage("Sled must be in home position!\n"); return 0; } if ((result = MechaCommandExecute(MECHA_CMD_TRAY, 6000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[1], "OPEN")) { if (!SledIsAtHome) { - printf("Sled must be in home position!\n"); + PlatShowMessage("Sled must be in home position!\n"); return 0; } if ((result = MechaCommandExecute(MECHA_CMD_TRAY, 6000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[1], "IN-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_TRAY_SW, 3000, "00", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("IN-SW: %s\n", buffer); + PlatShowMessage("IN-SW: %s\n", buffer); } else if (!pstricmp(argv[1], "OUT-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_TRAY_SW, 3000, "01", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("OUT-SW: %s\n", buffer); + PlatShowMessage("OUT-SW: %s\n", buffer); } else return -EINVAL; @@ -874,23 +874,23 @@ static int MechaAdjJitter(short int argc, char *argv[]) if (!pstricmp(argv[1], "1")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 1000, "00", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else if (!pstricmp(argv[1], "16")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 1000, "02", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else if (!pstricmp(argv[1], "256")) { if ((result = MechaCommandExecute(MECHA_CMD_JITTER, 2000, "01", buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else - printf("%s\n", &buffer[1]); + PlatShowMessage("%s\n", &buffer[1]); } else return -EINVAL; @@ -919,7 +919,7 @@ static int MechaAdjGetError(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_DSP_ERROR_RATE, "00", id++, MECHA_CMD_TAG_MECHA_DVD_ERROR_RATE, 2000, "DVD GET DSP ERROR RATE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) == 0) { - printf("DVD Error Data:\n" + PlatShowMessage("DVD Error Data:\n" "PI Correct:\t\t%#04x\tPO Correct:\t\t%#04x\n" "PI Non-correct:\t%#04x\tPO Non-correct:\t%#04x\n" "PI Max:\t\t\t%#04x\tPO Max:\t\t\t%#04x\n" @@ -929,10 +929,10 @@ static int MechaAdjGetError(short int argc, char *argv[]) DvdError.jitter); } else - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); break; default: - printf("Not in a DVD PLAY mode.\n"); + PlatShowMessage("Not in a DVD PLAY mode.\n"); } } else if (!pstricmp(argv[1], "CD")) @@ -947,13 +947,13 @@ static int MechaAdjGetError(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_CD_ERROR, "00", id++, MECHA_CMD_TAG_MECHA_CD_ERROR_RATE, 2000, "CD GET DSP ERROR RATE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) == 0) { - printf("%04x:::%04x\n", CdError.c1, CdError.c2); + PlatShowMessage("%04x:::%04x\n", CdError.c1, CdError.c2); } else - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); break; default: - printf("Not in a CD PLAY mode.\n"); + PlatShowMessage("Not in a CD PLAY mode.\n"); } } else @@ -972,26 +972,26 @@ static int MechaAdjSled(short int argc, char *argv[]) if (!pstricmp(argv[1], "HOME")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_POS_HOME, 3000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else SledIsAtHome = 1; } else if (!pstricmp(argv[1], "IN")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 2000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "OUT")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 3000, "02", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "MID")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_POS, 3000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[1], "STEP-M")) @@ -1000,16 +1000,16 @@ static int MechaAdjSled(short int argc, char *argv[]) { if (!pstricmp(argv[2], "IN")) { // Micro reverse - sprintf(args, "00%04x", StepAmount); + snprintf(args, 7, "00%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_MICRO, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[2], "OUT")) { // Micro forward - sprintf(args, "01%04x", StepAmount); + snprintf(args, 7, "01%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_MICRO, 2000, "010064", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else @@ -1024,16 +1024,16 @@ static int MechaAdjSled(short int argc, char *argv[]) { if (!pstricmp(argv[2], "IN")) { // Biphs reverse - sprintf(args, "00%04x", StepAmount); + snprintf(args, 7, "00%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_BIPHS, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else if (!pstricmp(argv[2], "OUT")) { // Biphs forward - sprintf(args, "01%04x", StepAmount); + snprintf(args, 7, "01%04x", StepAmount); if ((result = MechaCommandExecute(MECHA_CMD_SLED_CTL_BIPHS, 2000, args, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); SledIsAtHome = 0; } else @@ -1049,12 +1049,12 @@ static int MechaAdjSled(short int argc, char *argv[]) if (!pstricmp(argv[2], "ON")) { if ((result = MechaCommandExecute(MECHA_CMD_TRACKING, 1000, "01", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else if (!pstricmp(argv[2], "OFF")) { if ((result = MechaCommandExecute(MECHA_CMD_TRACKING, 1000, "00", buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); } else return -EINVAL; @@ -1065,11 +1065,11 @@ static int MechaAdjSled(short int argc, char *argv[]) else if (!pstricmp(argv[1], "IN-SW")) { if ((result = MechaCommandExecute(MECHA_CMD_SLED_IN_SW, 1000, NULL, buffer, sizeof(buffer))) < 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { result = (int)strtoul(&buffer[1], NULL, 16); - printf("IN-SW: %02x\n", result); + PlatShowMessage("IN-SW: %02x\n", result); } } else if (!pstricmp(argv[1], "STEP")) @@ -1077,7 +1077,7 @@ static int MechaAdjSled(short int argc, char *argv[]) if (argc == 3) { StepAmount = (unsigned short int)strtoul(argv[2], NULL, 0); - printf("STEP: %u\n", StepAmount); + PlatShowMessage("STEP: %u\n", StepAmount); } else return -EINVAL; @@ -1098,11 +1098,11 @@ static int DisplayHelp(const struct MechaDiagCommand *commands, short int argc, if (argc == 1) { - printf("To get help for a specific command, type HELP \n" + PlatShowMessage("To get help for a specific command, type HELP \n" "Available commands:\n"); for (pCmd = commands, i = 0; pCmd->command != NULL; pCmd++, i++) { - printf("\t%s%c", pCmd->command, ((i != 0) && (i % 4) == 0) ? '\n' : ' '); + PlatShowMessage("\t%s%c", pCmd->command, ((i != 0) && (i % 4) == 0) ? '\n' : ' '); } putchar('\n'); } @@ -1112,13 +1112,13 @@ static int DisplayHelp(const struct MechaDiagCommand *commands, short int argc, { if (!pstricmp(pCmd->command, argv[1])) { - printf("%s - %s\n", pCmd->syntax, pCmd->description); + PlatShowMessage("%s - %s\n", pCmd->syntax, pCmd->description); break; } } if (pCmd->command == NULL) - printf("No such command.\n"); + PlatShowMessage("No such command.\n"); } else { @@ -1155,7 +1155,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) if (!pstricmp(argv[1], "CD")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_CD_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_CD; @@ -1165,7 +1165,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) else if (!pstricmp(argv[1], "DVD-SL")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_DVDSL_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_DVDSL; @@ -1175,7 +1175,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) else if (!pstricmp(argv[1], "DVD-DL")) { if ((result = MechaCommandExecute(MECHA_CMD_DISC_MODE_DVDDL_12, 1000, NULL, buffer, sizeof(buffer))) < 0 || (result = strtoul(buffer, NULL, 16)) != 0) - printf("Error %d\n", result); + PlatShowMessage("Error %d\n", result); else { status = MECHA_ADJ_STATE_DVDDL; @@ -1187,7 +1187,7 @@ static int MechaTestDiscControl(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_DISC_DETECT, NULL, id++, MECHA_CMD_TAG_MECHA_DISC_DETECT, 3000, "DISC DETECT"); MechaCommandAdd(MECHA_CMD_DISC_MODE_CD_8, NULL, id++, MECHA_CMD_TAG_MECHA_SET_DISC_TYPE, 1000, "DISC MODE CD 8cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1209,13 +1209,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_LASER_DIODE, "01", id++, 0, 3000, "LD ON"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "OFF")) { MechaCommandAdd(MECHA_CMD_LASER_DIODE, "00", id++, 0, 3000, "LD OFF"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1232,13 +1232,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "01", id++, 0, 3000, "FOCUS UP/DOWN START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[3], "STOP")) { MechaCommandAdd(MECHA_CMD_FOCUS_UPDOWN, "00", id++, 0, 3000, "FOCUS UP/DOWN STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1249,13 +1249,13 @@ static int MechaTestLaserControl(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_AUTO_START, NULL, id++, 0, 3000, "AUTO FOCUS START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[3], "STOP")) { MechaCommandAdd(MECHA_CMD_FOCUS_AUTO_STOP, NULL, id++, 0, 3000, "AUTO FOCUS STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1281,7 +1281,7 @@ static int MechaTestServoControl(short int argc, char *argv[]) if (DiscDetect == 0xFF) { - printf("Disc type/circuit not set up!\n"); + PlatShowMessage("Disc type/circuit not set up!\n"); return 0; } @@ -1293,7 +1293,7 @@ static int MechaTestServoControl(short int argc, char *argv[]) MechaCommandAdd(MECHA_CMD_SLED_POS_HOME, NULL, id++, 0, 3000, "SLED HOME"); MechaCommandAdd(MECHA_CMD_AUTO_ADJ_ST_12, "00", id++, 0, 40000, "SERVO AUTO ADJ START"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1310,7 +1310,7 @@ static int MechaTestPlay(short int argc, char *argv[]) if (DiscDetect == 0xFF) { - printf("Disc type/circuit not set up!\n"); + PlatShowMessage("Disc type/circuit not set up!\n"); return 0; } @@ -1324,7 +1324,7 @@ static int MechaTestPlay(short int argc, char *argv[]) case DISC_TYPE_CD12: MechaCommandAdd(MECHA_CMD_CD_PLAY_1, NULL, id++, 0, 3000, "PLAY CD 12cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); else status = MECHA_ADJ_STATE_CD_1; break; @@ -1332,7 +1332,7 @@ static int MechaTestPlay(short int argc, char *argv[]) case DISC_TYPE_DVDD12: MechaCommandAdd(MECHA_CMD_DVD_PLAY_1, NULL, id++, 0, 5000, "PLAY DVD 12cm"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); else { switch (DiscDetect) @@ -1356,10 +1356,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_CTL, "01000A", id++, 0, 5000, "CD FWD 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1367,10 +1367,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_CTL, "01000A", id++, 0, 5000, "DVD FWD 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "REV")) @@ -1382,10 +1382,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_CTL, "00000A", id++, 0, 5000, "CD REV 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1393,10 +1393,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_CTL, "00000A", id++, 0, 5000, "DVD REV 1 TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "FWDL")) @@ -1408,10 +1408,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_LONG_CTL, "010001", id++, 0, 10000, "CD FWD LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1419,10 +1419,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_LONG_CTL, "010001", id++, 0, 10000, "DVD FWD LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "REVL")) @@ -1434,10 +1434,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_TRACK_LONG_CTL, "000001", id++, 0, 10000, "CD REV LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1445,10 +1445,10 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_TRACK_LONG_CTL, "000001", id++, 0, 10000, "DVD REV LONG TRACK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "STOP")) @@ -1460,12 +1460,12 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_CD_STOP, NULL, id++, 0, 20000, "CD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); status = MECHA_ADJ_STATE_CD; } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); break; case DISC_TYPE_DVDS12: case DISC_TYPE_DVDD12: @@ -1473,7 +1473,7 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_DVD_STOP, NULL, id++, 0, 20000, "DVD STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); switch (status) { @@ -1485,7 +1485,7 @@ static int MechaTestPlay(short int argc, char *argv[]) } } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } } else if (!pstricmp(argv[1], "FJ")) @@ -1496,13 +1496,13 @@ static int MechaTestPlay(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_FOCUS_JUMP, "0205", id++, 0, 2000, "DVD-DL FOCUS JUMP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else - printf("Not in PLAY mode.\n"); + PlatShowMessage("Not in PLAY mode.\n"); } else - printf("Not a DVD-DL.\n"); + PlatShowMessage("Not a DVD-DL.\n"); } else return -EINVAL; @@ -1524,31 +1524,31 @@ static int MechaTestSpindle(short int argc, char *argv[]) { MechaCommandAdd(MECHA_CMD_SP_CTL, "01", id++, 0, 3000, "SP KICK"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "BRAKE")) { MechaCommandAdd(MECHA_CMD_SP_CTL, "00", id++, 0, 3000, "SP BRAKE"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "STOP")) { MechaCommandAdd(MECHA_CMD_SP_CTL, "02", id++, 0, 3000, "SP STOP"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "CLV-S")) { MechaCommandAdd(MECHA_CMD_SP_CLV_S, NULL, id++, 0, 3000, "SP CLV-S"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else if (!pstricmp(argv[1], "CLV-A")) { MechaCommandAdd(MECHA_CMD_SP_CLV_A, NULL, id++, 0, 3000, "SP CLV-A"); if (MechaCommandExecuteList(&MechaAdjTxHandler, &MechaAdjRxHandler) != 0) - printf("Failed to execute.\n"); + PlatShowMessage("Failed to execute.\n"); } else return -EINVAL; @@ -1576,7 +1576,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt previous[0] = '\0'; do { - printf("MD1.%d %c> ", md, prompt); + PlatShowMessage("MD1.%d %c> ", md, prompt); if (fgets(input, sizeof(input), stdin)) { input[strlen(input) - 1] = '\0'; @@ -1603,7 +1603,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt if ((result = pCmd->function(argc, argv)) < 0) { if (result == -EINVAL) - printf(MECHA_ADJ_SYNTAX_ERR); + PlatShowMessage(MECHA_ADJ_SYNTAX_ERR); } else { @@ -1611,7 +1611,7 @@ static void MechaCommonMain(const struct MechaDiagCommand *commands, char prompt } } else - printf("Unrecognized command. For help, type HELP.\n"); + PlatShowMessage("Unrecognized command. For help, type HELP.\n"); } } while (!done); } @@ -1631,7 +1631,7 @@ static int MechaAdjPromptT10K(void) char input; do { - printf("Is this a DTL-T10000? [y,n] "); + PlatShowMessage("Is this a DTL-T10000? [y,n] "); input = getchar(); while (getchar() != '\n') { @@ -1654,13 +1654,13 @@ void MenuMECHA(void) } if (IsOutdatedBCModel()) { - printf("B/C-chassis: EEPROM update required.\n"); + PlatShowMessage("B/C-chassis: EEPROM update required.\n"); return; } do { - printf("\nMechanics (skew) Adjustment\n" + PlatShowMessage("\nMechanics (skew) Adjustment\n" "This tool allows you to re-calibrate and test the mechanics (skew) of the CD/DVD drive.\n" "You need to do this if you:\n" "\t1. Change/remove the OPtical (OP) block\n" @@ -1683,7 +1683,7 @@ void MenuMECHA(void) { do { - printf("\nMechanics (skew) Adjustment\n" + PlatShowMessage("\nMechanics (skew) Adjustment\n" "\t1. Adjust mechanics\n" "\t2. Test mechanics\n" "\t3. Quit\n" diff --git a/base/mecha.c b/base/mecha.c index d40e9ef..d3236b6 100644 --- a/base/mecha.c +++ b/base/mecha.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "platform.h" #include "mecha.h" @@ -15,6 +16,19 @@ char MechaName[9], RTCData[19]; static struct MechaIdentRaw MechaIdentRaw; unsigned char ConMD, ConType, ConTM, ConCEXDEX, ConOP, ConLens, ConRTC, ConRTCStat, ConECR, ConChecksumStat, ConSlim; +int is_valid_data(const char *data, int size) +{ + // Validate the received data + for (int i = 0; i < size; i++) + { + if (!isprint((unsigned char)data[i])) + { + return 0; + } + } + return 1; +} + int MechaCommandAdd(unsigned short int command, const char *args, unsigned char id, unsigned char tag, unsigned short int timeout, const char *label) { struct MechaTask *task; @@ -52,9 +66,9 @@ int MechaCommandExecute(unsigned short int command, unsigned short int timeout, int result = 0; if (args != NULL) - sprintf(cmd, "%03x%s\r\n", command, args); + snprintf(cmd, sizeof(cmd), "%03x%s\r\n", command, args); else - sprintf(cmd, "%03x\r\n", command); + snprintf(cmd, sizeof(cmd), "%03x\r\n", command); PlatDPrintf("PlatWriteCOMPort: %s", cmd); @@ -144,9 +158,18 @@ int MechaCommandExecuteList(MechaCommandTxHandler_t transmit, MechaCommandRxHand } else { + if (result == -EPIPE) + { + if (!is_valid_data(RxBuffer, size)) + { + PlatShowEMessage("Error: Connection problems, received invalid data for task ID %02d.\n", task->id); + result = -1; // Indicate an error + break; + } + PlatShowEMessage("%02d. %04x%s %s: 101 - rx-Command timed out\n", task->id, task->command, task->args, task->label); - break; + } } if (receive != NULL) @@ -579,7 +602,7 @@ int MechaInitModel(void) { for (i = 0; EEPMapToInit[i] != 0xFFFF; i++, id++) { - sprintf(address, "%04x", EEPMapToInit[i]); + snprintf(address, 5, "%04x", EEPMapToInit[i]); if ((result = MechaCommandAdd(MECHA_CMD_EEPROM_READ, address, id, MECHA_CMD_TAG_INIT_EEP_READ, MECHA_TASK_NORMAL_TO, "READ EEPROM")) != 0) break; } @@ -812,7 +835,7 @@ int MechaAddPostUpdateCmds(unsigned char ClearOSD2InitBit, unsigned char id) { if (ClearOSD2InitBit) { - sprintf(value, "%04x%04x", EEPROM_MAP_OSD2_17, EEPMapRead(EEPROM_MAP_OSD2_17) & ~0x80); + snprintf(value, 9, "%04x%04x", EEPROM_MAP_OSD2_17, EEPMapRead(EEPROM_MAP_OSD2_17) & ~0x80); MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, value, id++, 0, MECHA_TASK_NORMAL_TO, "CLEAR OSD2 INIT BIT"); } @@ -840,7 +863,7 @@ int MechaAddPostUpdateCmds(unsigned char ClearOSD2InitBit, unsigned char id) { if (ClearOSD2InitBit) { - sprintf(value, "%04x%04x", EEPROM_MAP_OSD2_17_NEW, EEPMapRead(EEPROM_MAP_OSD2_17_NEW) & ~0x80); + snprintf(value, 9, "%04x%04x", EEPROM_MAP_OSD2_17_NEW, EEPMapRead(EEPROM_MAP_OSD2_17_NEW) & ~0x80); MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, value, id++, 0, MECHA_TASK_NORMAL_TO, "CLEAR OSD2 INIT BIT"); } @@ -1228,6 +1251,6 @@ void MechaGetTimeString(char *TimeString) if (TimeInfo->tm_year + 1900 >= 2000) month |= 0x80; //'99 -> '00 Century bit year = itob(TimeInfo->tm_year % 100); - sprintf(TimeString, "%02x%02x%02x%02x%02x%02x%02x", itob(TimeInfo->tm_sec), itob(TimeInfo->tm_min), itob(TimeInfo->tm_hour), itob(TimeInfo->tm_wday), - itob(TimeInfo->tm_mday), month, year); + snprintf(TimeString, 15, "%02x%02x%02x%02x%02x%02x%02x", itob(TimeInfo->tm_sec), itob(TimeInfo->tm_min), itob(TimeInfo->tm_hour), itob(TimeInfo->tm_wday), + itob(TimeInfo->tm_mday), month, year); } diff --git a/PMAP/platform.h b/base/platform.h similarity index 100% rename from PMAP/platform.h rename to base/platform.h diff --git a/base/updates.c b/base/updates.c index e7acc00..b5a8bcc 100644 --- a/base/updates.c +++ b/base/updates.c @@ -21,7 +21,7 @@ struct UpdateData static int AddUpdateItem(u16 word, u16 value, unsigned char index) { char args[16]; - sprintf(args, "%04x%04x", word, value); + snprintf(args, 9, "%04x%04x", word, value); return MechaCommandAdd(MECHA_CMD_EEPROM_WRITE, args, index, 0, MECHA_TASK_NORMAL_TO, "EEPROM WRITE"); }