Skip to content

Commit

Permalink
Allow fast speed connections (for dolphin) with slow fallback
Browse files Browse the repository at this point in the history
Allow fast speed connections (for dolphin) with slow fallback
  • Loading branch information
KittyPBoxx committed Jan 17, 2024
1 parent 18ffbbc commit f82ebc9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion PokecomChannel/NoUITestChannel/PokecomDebug/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<app version="1">
<name>Pokecom Channel - Debug</name>
<coder>KittyPBoxx</coder>
<version>0.1.0</version>
<version>0.1.1</version>
<release_date>20240112135633</release_date>
<short_description>Pokecom Channel - Debug</short_description>
<long_description>Pokecom Channel is a wii channel designed to give gen 3 games a network connection.
Expand Down
9 changes: 5 additions & 4 deletions PokecomChannel/PokecomChannel/source/linkcableclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void setupGBAConnectors()
(void *) port0, /* arg pointer for thread */
NULL, /* stack base */
16*1024, /* stack size */
200 /* thread priority */ );
250 /* thread priority */ );


u8 *port1 = malloc(sizeof(*port1));
Expand All @@ -369,7 +369,7 @@ void setupGBAConnectors()
(void *) port1, /* arg pointer for thread */
NULL, /* stack base */
16*1024, /* stack size */
200 /* thread priority */ );
240 /* thread priority */ );

u8 *port2 = malloc(sizeof(*port2));
*port2 = 2;
Expand All @@ -378,7 +378,7 @@ void setupGBAConnectors()
(void *) port2, /* arg pointer for thread */
NULL, /* stack base */
16*1024, /* stack size */
200 /* thread priority */ );
230 /* thread priority */ );

u8 *port3 = malloc(sizeof(*port3));
*port3 = 3;
Expand All @@ -387,7 +387,7 @@ void setupGBAConnectors()
(void *) port3, /* arg pointer for thread */
NULL, /* stack base */
16*1024, /* stack size */
200 /* thread priority */ );
220 /* thread priority */ );

}

Expand Down Expand Up @@ -761,6 +761,7 @@ static void *seriald (void * port)
{
print_ui_log("SERIAL ERROR");
LOG_NS("Connection Error Resetting...\n");
switchToSlowTransfer();
connector.requestSend = 0;
connector.requestReceive = 0;
connector.requestStop = 0;
Expand Down
2 changes: 1 addition & 1 deletion PokecomChannel/PokecomChannel/source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ static int MenuSettings(GuiSound* bgMusic)
isMuted = true;
}

if (forceUiRefreshLoop == 300)
if (forceUiRefreshLoop == 1000)
{
forceUiRefreshLoop = 0;
HaltGui();
Expand Down
26 changes: 17 additions & 9 deletions PokecomChannel/PokecomChannel/source/seriallink.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@
#define SI_WRITE 0x15
#define SI_RESET 0xFF

#define SI_TRANS_DELAY 160 // Minimum delay between data transfers (any faster and data might be missed)
#define SI_TRANS_DELAY_FAST 50 // Minimum delay between data transfers (any faster and data might be missed)
#define SI_TRANS_DELAY_SLOW 160

u32 transDelay = SI_TRANS_DELAY_FAST;

#define MAX_MSG_SIZE 4096

#define VIRTUAL_CHANNEL_SIZE 16

#define MAX_CONNECTION_LOOPS 1000

static void switchToSlowTransfer()
{
transDelay = SI_TRANS_DELAY_SLOW;
}

u32 ch0DeviceType = 0;
u32 ch1DeviceType = 0;
u32 ch2DeviceType = 0;
Expand Down Expand Up @@ -209,15 +217,15 @@ static int SL_recv(u8 channel, u8 pktIn[4])
pktIn, // In buffer
4, // In msg length
SL_getTransmissionFinishedCallback(channel), // transfer finished callback
SI_TRANS_DELAY); // Delay between transfers
transDelay); // Delay between transfers

for (int i = 0; SL_isTransmissionFinished(channel) == 0; i++)
{
if (i > MAX_CONNECTION_LOOPS)
{
return -1;
}
usleep(SI_TRANS_DELAY);
usleep(transDelay);
}
return 0;
}
Expand All @@ -241,15 +249,15 @@ static int SL_send(u8 channel, u32 msg)
pktIn,
1,
SL_getTransmissionFinishedCallback(channel),
SI_TRANS_DELAY);
transDelay);

for (int i = 0; SL_isTransmissionFinished(channel) == 0; i++)
{
if (i > MAX_CONNECTION_LOOPS)
{
return -1;
}
usleep(SI_TRANS_DELAY);
usleep(transDelay);
}
return 0;
}
Expand All @@ -268,15 +276,15 @@ static int SL_reset(u8 channel)
pktIn,
4,
SL_getTransmissionFinishedCallback(channel),
SI_TRANS_DELAY);
transDelay);

for (int i = 0; SL_isTransmissionFinished(channel) == 0; i++)
{
if (i > MAX_CONNECTION_LOOPS)
{
return -1;
}
usleep(SI_TRANS_DELAY);
usleep(transDelay);
}
return 0;
}
Expand All @@ -293,15 +301,15 @@ static int SL_getstatus(u8 channel, u8 pktIn[4])
pktIn,
4,
SL_getTransmissionFinishedCallback(channel),
SI_TRANS_DELAY);
transDelay);

for (int i = 0; SL_isTransmissionFinished(channel) == 0; i++)
{
if (i > MAX_CONNECTION_LOOPS)
{
return -1;
}
usleep(SI_TRANS_DELAY);
usleep(transDelay);
}
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion PokecomChannel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ If you have issues see the troubleshooting step***

## Debugging

A debug version of the channel is available that prints out messages to the screen. Alternatively you can compile the UI channel with `#define USE_UI TRUE` set to false in `main.cpp` and `#define ENABLE_DEBUG_LOG` commented out in `linkcableclient.c`
On the wii channel main screen you can press `minus` for some debug info.

A debug version of the channel is available that prints out messages to the screen. Alternatively you can compile the UI channel with `#define USE_UI TRUE` set to false in `main.cpp`

## Resolving Addresses

Expand Down

0 comments on commit f82ebc9

Please sign in to comment.