From f8f33ea7c270caba1d03ff30c353525278f397f8 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 4 Sep 2022 22:46:59 +0200 Subject: [PATCH] Use libmocha --- Makefile | 4 ++-- source/main.cpp | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 04ae20f..bc9bf2f 100644 --- a/Makefile +++ b/Makefile @@ -48,13 +48,13 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g endif -LIBS := -lwums -lwut -lkernel +LIBS := -lwums -lwut -lkernel -lmocha #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level # containing include and lib #------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUMS_ROOT) +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr $(WUMS_ROOT) #------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional diff --git a/source/main.cpp b/source/main.cpp index e907b76..42c1e04 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging"); @@ -12,15 +13,16 @@ extern "C" void SC_0x51(); WUMS_INITIALIZE() { initLogging(); - // Start syslogging on iosu side - int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0); - if (mcpFd >= 0) { - int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING - int out = 0; - IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out)); - IOS_Close(mcpFd); - } else { - DEBUG_FUNCTION_LINE_ERR("Failed to open /dev/mcp"); + + int res; + if ((res = Mocha_InitLibrary()) != MOCHA_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Mocha_InitLibrary() failed %d", res); + return; + } + + if (Mocha_StartUSBLogging(false) != MOCHA_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Mocha_StartUSBLogging failed"); + return; } // Patch loader.elf to spit out less warnings when loading .rpx built with wut