Skip to content

Commit 8eb6b29

Browse files
committed
Merge remote-tracking branch 'upstream' into BDSPMoneyFarmer/ImproveReliability
2 parents 2b46a1e + 66697b7 commit 8eb6b29

8 files changed

Lines changed: 32 additions & 21 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SerialPrograms/bin/
22

33
.vscode
4+
.qtcreator
45

56
discord_social_sdk_win/
67
discord_partner_sdk.dll
@@ -73,3 +74,4 @@ CLAUDE.md
7374
build_*/
7475
.cache/*
7576
Packages/*
77+

Common/Cpp/StreamConnections/MockDevice.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ using std::cout;
1515
using std::endl;
1616

1717
#if 1
18-
#define PABB2_DROP_HOST_TO_DEVICE 0.2
19-
#define PABB2_DROP_DEVICE_TO_HOST 0.2
18+
#define PABB2_DROP_HOST_TO_DEVICE 0.01
19+
#define PABB2_DROP_DEVICE_TO_HOST 0.01
2020
#else
2121
#define PABB2_DROP_HOST_TO_DEVICE 0
2222
#define PABB2_DROP_DEVICE_TO_HOST 0
@@ -98,6 +98,9 @@ size_t MockDevice::device_read_serial(void* data, size_t max_bytes){
9898
auto iter1 = iter0 + bytes;
9999
std::copy(iter0, iter1, (uint8_t*)data);
100100
m_host_to_device_line.erase(iter0, iter1);
101+
102+
// cout << "device_read_serial(): attempt = " << max_bytes << ", actual = " << bytes << endl;
103+
101104
return bytes;
102105
}
103106

Common/PABotBase2/PABotBase2_PacketParser.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "Common/CRC32/pabb_CRC32.h"
88
#include "PABotBase2_PacketParser.h"
99

10+
//#include <stdio.h>
11+
1012

1113
const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
1214
pabb2_PacketParser* self,
@@ -27,6 +29,7 @@ const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
2729

2830
// Header is still incomplete.
2931
if (self->index < MIN_PACKET_SIZE){
32+
// printf("Incomplete Header: %d\n", self->index);
3033
return NULL;
3134
}
3235

@@ -43,20 +46,19 @@ const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
4346

4447
// Magic byte never found.
4548
if (c == MIN_PACKET_SIZE){
46-
self->index = 0;
4749
break;
4850
}
4951

5052
// Magic byte found.
5153
if (buffer[c] == PABB2_CONNECTION_MAGIC_NUMBER){
5254
// Shift the buffer up so that the magic byte is at the start.
5355
memmove(self->buffer, self->buffer + c, MIN_PACKET_SIZE - c);
54-
goto EndLoop;
56+
break;
5557
}
5658
}
57-
}
5859

59-
EndLoop:;
60+
self->index -= c;
61+
}
6062

6163
// At this point, we have a complete and valid header.
6264

@@ -87,6 +89,7 @@ EndLoop:;
8789

8890
// Packet is incomplete.
8991
if (self->index < packet_bytes){
92+
// printf("Incomplete Packet: %d\n", packet_bytes);
9093
return NULL;
9194
}
9295

Common/PABotBase2/PABotBase2_PacketSender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ bool pabb2_PacketSender_iterate_retransmits(pabb2_PacketSender* self){
299299
// Not old enough.
300300
if ((uint8_t)(seqnum - packet->magic_number) < PABB2_ConnectionSender_RETRANSMIT_COUNTER){
301301
#if 0
302-
printf("Not old enough.\n");
302+
printf("Not old enough: seqnum = %d, packet = %d\n", seqnum, packet->magic_number);
303303
fflush(stdout);
304304
#endif
305305
head++;

Common/PABotBase2/PABotBase2_StreamCoalescer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <string.h>
88
#include "PABotBase2_StreamCoalescer.h"
99

10-
//#include <stdio.h> // REMOVE
11-
//#include "PABotBase2_ConnectionDebug.h" // REMOVE
10+
//#include <stdio.h>
11+
//#include "PABotBase2_ConnectionDebug.h"
1212

1313
void pabb2_StreamCoalescer_init(pabb2_StreamCoalescer* self){
1414
// printf("pabb2_StreamCoalescer_init(%p)\n", self);

Common/PABotBase2/PABotbase2_ReliableStreamConnection.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
*/
66

7-
#include <stdio.h> // REMOVE
7+
//#include <stdio.h>
88
#include "PABotBase2_ConnectionDebug.h"
99
#include "PABotbase2_ReliableStreamConnection.h"
1010

@@ -44,26 +44,28 @@ void pabb2_ReliableStreamConnection_run_events(pabb2_ReliableStreamConnection* s
4444
case PABB2_PacketParser_RESULT_VALID:
4545
break;
4646
case PABB2_PacketParser_RESULT_INVALID:
47-
printf("PABB2_PacketParser_RESULT_INVALID\n");
47+
// printf("PABB2_PacketParser_RESULT_INVALID\n");
4848
pabb2_PacketSender_send_info(
4949
&self->reliable_sender,
5050
packet->seqnum,
5151
PABB2_CONNECTION_OPCODE_INVALID_LENGTH
5252
);
5353
return;
5454
case PABB2_PacketParser_RESULT_CHECKSUM_FAIL:
55-
printf("PABB2_PacketParser_RESULT_CHECKSUM_FAIL\n");
55+
// printf("PABB2_PacketParser_RESULT_CHECKSUM_FAIL\n");
5656
pabb2_PacketSender_send_info(
5757
&self->reliable_sender,
5858
packet->seqnum,
5959
PABB2_CONNECTION_OPCODE_INVALID_CHECKSUM_FAIL
6060
);
6161
return;
6262
default:
63-
printf("Internal Error: Unrecognized packet state.\n");
63+
// printf("Internal Error: Unrecognized packet state.\n");
6464
return;
6565
}
6666

67+
// printf("Device Received: %d\n", packet->opcode);
68+
6769
// Now handle the different opcodes.
6870
switch (packet->opcode){
6971
case PABB2_CONNECTION_OPCODE_ASK_RESET:
@@ -124,10 +126,10 @@ void pabb2_ReliableStreamConnection_run_events(pabb2_ReliableStreamConnection* s
124126
pabb2_StreamCoalescer_bytes_available(&self->stream_coalescer)
125127
);
126128
}else{
127-
printf("Device: Failed to push.\n");
129+
// printf("Device: Failed to push.\n");
128130
pabb2_StreamCoalescer_print(&self->stream_coalescer, true);
129131
}
130-
fflush(stdout);
132+
// fflush(stdout);
131133
return;
132134
default:
133135
pabb2_PacketSender_send_info(

SerialPrograms/BuildInstructions/Build-Windows-Qt6.10.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Unlike with Qt 5.12, there is no offline installer for it. So you have two optio
2121

2222
If you are ok with creating an account with Qt and using their online installer, then use this method.
2323

24-
1. Download the online installer from here: https://www.qt.io/download-qt-Images/
24+
1. Download the online installer from here: [https://www.qt.io/download-qt-Images/](https://www.qt.io/development/download-qt-installer-oss)
2525
3. Select the following options:
2626
- Qt 6.10.0
2727
- MSVC 2022 64-bit
@@ -80,3 +80,4 @@ TODO
8080
[<img src="https://canary.discordapp.com/api/guilds/695809740428673034/widget.png?style=banner2">](https://discord.gg/cQ4gWxN)
8181

8282

83+

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void stress_test(Logger& logger, CancellableScope& scope){
300300

301301
ReliableStreamConnection connection(
302302
&scope,
303-
logger, true,
303+
logger, false,
304304
GlobalThreadPools::unlimited_realtime(),
305305
device,
306306
100ms,
@@ -326,6 +326,10 @@ void stress_test(Logger& logger, CancellableScope& scope){
326326
const char* ptr = data.data();
327327
size_t left = data.size();
328328
while (left > 0){
329+
if (current_time() - last_print > Seconds(1)){
330+
cout << "Bytes Sent = " << bytes_sent + data.size() - left << endl;
331+
last_print = current_time();
332+
}
329333
// scope.wait_for(Milliseconds(rand() % 100));
330334
size_t sent = connection.send(ptr, left);
331335
if (sent == 0){
@@ -335,10 +339,6 @@ void stress_test(Logger& logger, CancellableScope& scope){
335339
left -= sent;
336340
}
337341
bytes_sent += data.size();
338-
if (current_time() - last_print > Seconds(1)){
339-
cout << "Bytes Sent = " << bytes_sent << endl;
340-
last_print = current_time();
341-
}
342342
device.push_expected_stream_data(data.data(), data.size());
343343
}
344344
}

0 commit comments

Comments
 (0)