Skip to content

Commit a2179fb

Browse files
committed
Allow negative (i.e. high) values in M122 P1007
1 parent e39d3ad commit a2179fb

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/CAN/CanInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,18 +1173,18 @@ GCodeResult CanInterface::RemoteDiagnostics(MessageType mt, uint32_t boardAddres
11731173
if (type == (uint16_t)DiagnosticTestType::AccessMemory)
11741174
{
11751175
gb.MustSee('A');
1176-
msg->param32[0] = gb.GetUIValue();
1176+
msg->param32[0] = (uint32_t)gb.GetIValue(); // allow negative values so that we can read high memory addresses
11771177
if (gb.Seen('V'))
11781178
{
1179-
msg->param32[1] = gb.GetUIValue();
1179+
msg->param32[1] = (uint32_t)gb.GetIValue(); // allow negative values so that we set high values
11801180
msg->param16 = 1;
11811181
}
11821182
else
11831183
{
11841184
msg->param16 = 0;
11851185
}
11861186
}
1187-
return SendRequestAndGetStandardReply(buf, rid, reply); // we may not actually get a reply if the test is one that crashes the expansion board
1187+
return SendRequestAndGetStandardReply(buf, rid, reply); // we may not actually get a reply if the test is one that crashes the expansion board
11881188
}
11891189

11901190
GCodeResult CanInterface::RemoteM408(uint32_t boardAddress, unsigned int type, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException)

src/Platform/Platform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,16 +2035,16 @@ GCodeResult Platform::DiagnosticTest(GCodeBuffer& gb, const StringRef& reply, Ou
20352035
case (unsigned int)DiagnosticTestType::AccessMemory:
20362036
{
20372037
gb.MustSee('A');
2038-
uint32_t address = gb.GetUIValue();
2038+
uint32_t address = (uint32_t)gb.GetIValue(); // allow negative values here so that we can read high addresses
20392039
unsigned int numValues = (gb.Seen('R')) ? gb.GetUIValue() : 1;
2040-
uint32_t val;
2040+
int32_t val;
20412041
bool dummy;
20422042
deliberateError = true; // in case the memory access causes a fault
2043-
if (gb.TryGetUIValue('V', val, dummy))
2043+
if (gb.TryGetIValue('V', val, dummy)) // allow negative values so that we can use values like 0xffffffff
20442044
{
20452045
while (numValues != 0)
20462046
{
2047-
*reinterpret_cast<uint32_t*>(address) = val;
2047+
*reinterpret_cast<uint32_t*>(address) = (uint32_t)val;
20482048
address += 4;
20492049
--numValues;
20502050
}

0 commit comments

Comments
 (0)