Skip to main content
Submitted by JMRibault on Wed, 08/26/2015 - 15:21

Hi All,

I have a DMC 21x3 and I am try to get the GMessage to work with gclib. Galil Tools connects with no issue and I can see the unsolicited messages. I can load my DMC program and every thing is fine.

When I compile with MSVC 2012 (32 bits), I have the following issues.
If I use Galil1.dll and lib (latest from the Galil site), the application crashes basic_string allocation (in the dll) on any function call
First-chance exception at 0x75b93e28 in Hello.exe: Microsoft C++ exception: std::basic_string<char,std::char_traits<char>,std::allocator<char> > at memory location 0x002be828.

If I use gclib, I can open connection, the loading of the program is inconsistent, (when I upload back, I have bunch on missing function, like if the compression removed functions) and not matter what I do, I cannot get unsolicited message (I try opening two handles etc... no dice

Here is a small version of my code (very basic)

Open the communication
char buf[1024]; //traffic buffer

try
{
if (m_g != 0)
{
GClose(m_g);
}
KillTimer(0x101);

GReturn gr = GOpen("192.168.1.250 -s ALL -t 1000 -d", &m_g); //connect and assign a value to m_g

GInfo(m_g, buf, sizeof(buf)); //grab connection string

gr = GProgramDownloadFile(m_g, "C:\\simpe.dmc", 0); // Loop on a function WT 1000, MG "Hello"

GSize bytes = 0;
gr = GCommand(m_g, "HX", buf, sizeof(buf), &bytes);
TRACE(buf);
TRACE("\n");

gr = GCommand(m_g, "XQ #main, 0", buf, sizeof(buf), &bytes);
TRACE(buf);
TRACE("\n");

gr = GCommand(m_g, "ver[0]=?", buf, sizeof(buf), &bytes);
TRACE(buf);
TRACE("\n");
gr = GCommand(m_g, "ver[1]=?", buf, sizeof(buf), &bytes);
TRACE(buf);
TRACE("\n");
SetTimer(0x101, 1000, NULL);
KillTimer(0x101);
}
catch (GReturn gr) //for x_e() function
{
if (gr == GALIL_EXAMPLE_ERROR)
{
TRACE("ERROR: Example code failed\n");
}
else
{
}
if (m_g) GClose(m_g); m_g = 0; //close g
KillTimer(0x101);
}
catch (std::exception& e)
{
std::cerr << "Unexpected std::exception... Kaboom. " << e.what() << std::endl;
if (m_g) GClose(m_g); m_g = 0; //close g
KillTimer(0x101);
}
catch (...)
{
if (m_g) GClose(m_g); m_g = 0; //close g
KillTimer(0x101);
}

OnTimer
if (m_g)
{
char buf[1024];

GTimeout(m_g, 0);
if ( GMessage(m_g, &buf[0], sizeof(buf) ) == G_NO_ERROR)
{
m_szGalilMsg = buf;
GetDlgItem(IDC_GALIL_MSG2)->UpdateData(0);
}
GTimeout(m_g, -1);

}

For the life of me, I cannot figure out what I am doing wrong... Any help would be appreciated...

Comments 1

troym_galil on 08/26/2015 - 16:57