Welcome, Guest
Username Password: Remember me
  • Page:
  • 1

TOPIC: Ending Host Mode

Ending Host Mode 4 years, 11 months ago #289

When I'm in host mode 2, and issue the EndHostMode() command, I get an "Invalid echo response received!" exception.


{
CriticalSectionLock __lock(&CsInterface); // internal access to the SMI interface
// initialize buffered movement
CMotionInterface->Initialize(CommInterface->NoOfMotors);
}

...

for(int i = 0; i < cnt; i++)
{
x = *p++;
y = *p++;

{
CriticalSectionLock __lock(&CsInterface); // internal access to the SMI interface
CMotionInterface->WritePosition(1, x);
CMotionInterface->WritePosition(2, y);
if (timerCounter < 2)
{
CMotionInterface->WriteClock(0, t);

// increment clock (must be powers of 2. eg. 128, 256, etc.)
t += timeDelta;
++timerCounter;
}
}

ReleaseSemaphore(PositionSemaphore, 1, NULL);

CString msg;
msg.Format(L"\t%d\n", ++total);
TRACE(msg);
}

...

TRACE(L"End Host Mode\n");
CMotionInterface->EndHostMode();

-----------------------------------------------------------


When I'm in host mode 1, and issue the WriteCmd("0MP"), I get an "Invalid echo response received!".

{
CriticalSectionLock __lock(&CsInterface); // internal access to the SMI interface
// initialize buffered movement
CMotionInterface->Initialize(CommInterface->NoOfMotors);
}

...

for(int i = 0; i < cnt; i++)
{
x = *p++;
y = *p++;

{
CriticalSectionLock __lock(&CsInterface); // internal access to the SMI interface
CMotionInterface->WritePosition(1, x);
CMotionInterface->WritePosition(2, y);
//if (timerCounter < 2)
{
CMotionInterface->WriteClock(0, t);

// increment clock (must be powers of 2. eg. 128, 256, etc.)
t += timeDelta;
//++timerCounter;
}
}

ReleaseSemaphore(PositionSemaphore, 1, NULL);

CString msg;
msg.Format(L"\t%d\n", ++total);
TRACE(msg);
}

...

TRACE(L"End Host Mode - 0\n");
CommInterface->WriteCmd("0MP");
char buf[64];
sprintf(buf, "1P=%d", x);
TRACE(L"End Host Mode - 1\n");
CommInterface->WriteCmd(buf);
sprintf(buf, "2P=%d", y);
TRACE(L"End Host Mode - 2\n");
CommInterface->WriteCmd(buf);
while(CMotionInterface->TrajectorySlots - CMotionInterface->SlotsNeeded[1] >= 4) Sleep(10);
TRACE(L"End Host Mode - 3\n");
CommInterface->WriteCmd("0G");

--------------------------------------------------

What am I doing wrong?

Thanks in advance.

Re: Ending Host Mode 4 years, 11 months ago #290

Never mind.

As I was reviewing the code snippets, I realized that I wasn't locking my critical section, so I had a conflict with my polling thread.

Regards.
  • Page:
  • 1
Moderators: hsummer, csearcy
Time to create page: 0.40 seconds