Skip to content

Commit

Permalink
replace printf with PlatShowMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
AKuHAK committed Jul 8, 2024
1 parent 8c4e7fb commit a001b0c
Show file tree
Hide file tree
Showing 12 changed files with 388 additions and 388 deletions.
36 changes: 18 additions & 18 deletions PMAP-unix/platform-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int PlatOpenCOMPort(const char *device)
if (ComPortHandle == -1)
{
// List available serial devices
printf("Available serial devices in /dev/:\n");
PlatShowMessage("Available serial devices in /dev/:\n");
DIR *dir;
const struct dirent *entry;

Expand All @@ -37,24 +37,24 @@ int PlatOpenCOMPort(const char *device)
{
if (strncmp(entry->d_name, "cu.", 3) == 0)
{
printf("/dev/%s\n", entry->d_name);
PlatShowMessage("/dev/%s\n", entry->d_name);
}
}
closedir(dir);
}

printf("Opening COM port: %s\n", device);
PlatShowMessage("Opening COM port: %s\n", device);

ComPortHandle = open(device, O_RDWR | O_NOCTTY | O_NDELAY);

if (ComPortHandle != -1)
{
printf("COM port opened successfully.\n");
PlatShowMessage("COM port opened successfully.\n");

fcntl(ComPortHandle, F_SETFL, 0);
if (tcgetattr(ComPortHandle, &options) == -1)
{
printf("Failed to get terminal attributes. Error code: %d\n", errno);
PlatShowMessage("Failed to get terminal attributes. Error code: %d\n", errno);
close(ComPortHandle);
ComPortHandle = -1;
return errno;
Expand All @@ -73,34 +73,34 @@ int PlatOpenCOMPort(const char *device)

if (tcsetattr(ComPortHandle, TCSANOW, &options) == -1)
{
printf("Failed to set terminal attributes. Error code: %d\n", errno);
PlatShowMessage("Failed to set terminal attributes. Error code: %d\n", errno);
close(ComPortHandle);
ComPortHandle = -1;
return errno;
}

if (tcflush(ComPortHandle, TCIOFLUSH) == -1)
{
printf("Failed to flush terminal I/O. Error code: %d\n", errno);
PlatShowMessage("Failed to flush terminal I/O. Error code: %d\n", errno);
close(ComPortHandle);
ComPortHandle = -1;
return errno;
}

RxTimeout = MECHA_TASK_NORMAL_TO;

printf("COM port configuration set.\n");
PlatShowMessage("COM port configuration set.\n");
result = 0;
}
else
{
result = errno;
printf("Failed to open COM port. Error code: %d\n", result);
PlatShowMessage("Failed to open COM port. Error code: %d\n", result);
}
}
else
{
printf("COM port is already open.\n");
PlatShowMessage("COM port is already open.\n");
result = EMFILE;
}

Expand All @@ -113,7 +113,7 @@ int PlatReadCOMPort(char *data, int n, unsigned short timeout)

if (ComPortHandle == -1)
{
printf("COM port is not open.\n");
PlatShowMessage("COM port is not open.\n");
return -1; // Return an error code indicating that the COM port is not open.
}

Expand All @@ -135,18 +135,18 @@ int PlatReadCOMPort(char *data, int n, unsigned short timeout)

if (result < 0)
{
printf("Read from COM port failed.\n");
PlatShowMessage("Read from COM port failed.\n");
}
}
else if (result == 0)
{
// Timeout
printf("Read from COM port timed out.\n");
PlatShowMessage("Read from COM port timed out.\n");
}
else
{
// Error
printf("Select function error.\n");
PlatShowMessage("Select function error.\n");
}

return result;
Expand All @@ -159,7 +159,7 @@ int PlatWriteCOMPort(const char *data)

if (result < 0)
{
printf("Write to COM port failed.\n");
PlatShowMessage("Write to COM port failed.\n");
}

return result;
Expand All @@ -169,14 +169,14 @@ void PlatCloseCOMPort(void)
{
if (ComPortHandle != -1)
{
printf("Closing COM port...\n");
PlatShowMessage("Closing COM port...\n");
close(ComPortHandle);
ComPortHandle = -1;
printf("COM port closed.\n");
PlatShowMessage("COM port closed.\n");
}
else
{
printf("COM port is already closed.\n");
PlatShowMessage("COM port is already closed.\n");
}
}

Expand Down
12 changes: 6 additions & 6 deletions PMAP-wincli/platform-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void ListSerialDevices()

if (QueryDosDevice(dosDeviceName, targetPath, sizeof(targetPath)) != 0)
{
printf("Found COM Port: %s\n", dosDeviceName);
printf("Target Path: %s\n", targetPath);
PlatShowMessage("Found COM Port: %s\n", dosDeviceName);
PlatShowMessage("Target Path: %s\n", targetPath);
}
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ int PlatWriteCOMPort(const char *data)

if (result < 0)
{
printf("Write to COM port failed.\n");
PlatShowMessage("Write to COM port failed.\n");
}

return result;
Expand All @@ -116,14 +116,14 @@ void PlatCloseCOMPort(void)
{
if (ComPortHandle != INVALID_HANDLE_VALUE)
{
printf("Closing COM port...\n");
PlatShowMessage("Closing COM port...\n");
CloseHandle(ComPortHandle);
ComPortHandle = INVALID_HANDLE_VALUE;
printf("COM port closed.\n");
PlatShowMessage("COM port closed.\n");
}
else
{
printf("COM port is already closed.\n");
PlatShowMessage("COM port is already closed.\n");
}
}

Expand Down
36 changes: 18 additions & 18 deletions PMAP-wingui/eeprom-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: ");
Expand All @@ -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: ");
Expand All @@ -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')
{
Expand All @@ -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')
{
Expand All @@ -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;
}
}
Expand Down
18 changes: 9 additions & 9 deletions PMAP-wingui/id-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern unsigned char ConType, ConCEXDEX;
{
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"
Expand Down Expand Up @@ -58,7 +58,7 @@ extern unsigned char ConType, ConCEXDEX;
{
if (!dex)
{
printf("Select model Name:\n"
PlatShowMessage("Select model Name:\n"
"\t1. SCPH-xx000 (Japan)\n"
"\t2. SCPH-xx001 (USA)\n"
"\t3. SCPH-xx002 (Australia)\n"
Expand All @@ -78,7 +78,7 @@ extern unsigned char ConType, ConCEXDEX;
}
else
{
printf("Select model Name:\n"
PlatShowMessage("Select model Name:\n"
"\t1. DTL-H50000\n"
"\t2. DTL-H50001\n"
"\t3. DTL-H50002\n"
Expand Down Expand Up @@ -113,7 +113,7 @@ extern unsigned char ConType, ConCEXDEX;
case 11:
case 12:
case 13:
printf("MechaInit: %s\n", MechaInitMechacon(choice, 0) == 0 ? "done" : "failed");
PlatShowMessage("MechaInit: %s\n", MechaInitMechacon(choice, 0) == 0 ? "done" : "failed");
break;
case 14:
done = 1;
Expand All @@ -130,7 +130,7 @@ extern unsigned char ConType, ConCEXDEX;
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;
Expand All @@ -140,7 +140,7 @@ extern unsigned char ConType, ConCEXDEX;
}
}
else
printf("MechaInit: Unsupported chassis.\n");
PlatShowMessage("MechaInit: Unsupported chassis.\n");
}
static void InitNTSCPALDefaults(void)
Expand All @@ -149,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"
Expand All @@ -164,10 +164,10 @@ 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;
}
} */
Expand Down
Loading

0 comments on commit a001b0c

Please sign in to comment.