News:

  • February 01, 2023, 10:35:36 AM

Login with username, password and session length

Author Topic: VISUAL C ETHERCMM  (Read 10109 times)

chrisatwan

  • Full Member
  • ***
  • Posts: 30
VISUAL C ETHERCMM
« on: August 05, 2011, 04:05:35 PM »
Has anyone compiled the visual c EtherCMM and gotten it to work? I need some guidance on getting this to work.

Thanks

JMB

  • Jr. Member
  • **
  • Posts: 15
Re: VISUAL C ETHERCMM
« Reply #1 on: August 05, 2011, 08:13:23 PM »
How oddly timely, I was just looking at this earlier today.  I found three problems with it:

- the path to hei.h was incorrect.  Moving hei.h into the source directory and changing the include line to read simply #include "hei.h" fixed this.

- the project is configured to link to hei32_2.lib.  This seems to have problems correctly initializing the transport (Winsock).  Changing it to link to hei32_3.dll fixed this problem.

- the path to hei32_x.lib had a similar problem.  Again, copying that file into the source directory and then going to Project->Settings and selecting the Link tab and changing the path to the file fixed that.  You will also need to copy the appropriate hei32_x.dll into the final .exe's directory.

Let me know if any of that is helpful.
Jacob
Jacob Berghofer
Robotics and Automation Engineering Technologist
E-One Moli Energy (Canada) Ltd, Maple Ridge, B.C.

chrisatwan

  • Full Member
  • ***
  • Posts: 30
Re: VISUAL C ETHERCMM
« Reply #2 on: August 06, 2011, 12:31:36 PM »
I am getting an error on timeGetTime in main function.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3463
    • Host Engineering
Re: VISUAL C ETHERCMM
« Reply #3 on: August 06, 2011, 03:59:30 PM »
That's a window API function.  Look at the documentation that comes with VS for that function (or look online at MSDN).  It will show you:
1. What header file(s) is needed
2. What MS .LIB you need to link against
3. Any operating system limitations (I don't think there are any)

chrisatwan

  • Full Member
  • ***
  • Posts: 30
Re: VISUAL C ETHERCMM
« Reply #4 on: August 08, 2011, 09:09:52 AM »
Trying to get this CCM to work is not going well. Has anyone used the HEISrc files to make their own VC++ program? I am just trying to read and write to V13000 via a H2-ECOM module. I have done this with the VB but the application needs to be written in VC++ and having troubles.

Thanks,
Christopher Atwan

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5788
  • Yes Pinky, Do-more will control the world!
Re: VISUAL C ETHERCMM
« Reply #5 on: August 08, 2011, 11:57:20 AM »
We are very sorry you are having problems. To be honest, this code hasn't been touched in a decade or so, for two primary reasons...1) very few folks used it, and 2) we are currently eyeballs deep in the MX project.

I pulled the code from version control and had exactly the issues that Jacob mentioned. After updating the project file to Visual Studio 2008, I changed the library reference in the project to link against HEI32_3.lib and pointed it to the proper directory. Other than the nuisance warning about the string functions being potentially unsafe (sure they are, but that's C/C++!!) it built and ran clean.

Not sure why you would be having problems with timeGetTime(), it linked fine for me. It can be replaced with GetTickCount() if timing isn't too critical, or you can construct you own high resolution time function using the low level CPU clock. Something like this works well:

DWORD GetHiResTime()
{
   LARGE_INTEGER count, freq;
   QueryPerformanceFrequency(&freq);
   QueryPerformanceCounter(&count);
   return (DWORD)((count.QuadPart * 1000) / freq.QuadPart);
}

That is the actual code that we use in DirectSOFT for all of our critical comm timing.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

chrisatwan

  • Full Member
  • ***
  • Posts: 30
Re: VISUAL C ETHERCMM
« Reply #6 on: August 09, 2011, 12:45:41 PM »
This is the error I am getting:

ETHERCCM.obj : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function _main
.\Debug/ETHERCCM.exe : fatal error LNK1120: 1 unresolved externals

This is the only one I get after changing the linker settings to HEI32_3


Thanks,
Christopher

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5788
  • Yes Pinky, Do-more will control the world!
Re: VISUAL C ETHERCMM
« Reply #7 on: August 09, 2011, 01:23:21 PM »
I'm not sure why it is unresolved, there should be a linker reference to WINMM.LIB which is where that function gets provided from.

In lieu of resolving the linker issue, you can use the function I specified below, but to make it easier still, just paste this into your code:

DWORD timeGetTime()
{
   LARGE_INTEGER count, freq;
   QueryPerformanceFrequency(&freq);
   QueryPerformanceCounter(&count);
   return (DWORD)((count.QuadPart * 1000) / freq.QuadPart);
}
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3463
    • Host Engineering
Re: VISUAL C ETHERCMM
« Reply #8 on: August 09, 2011, 05:40:29 PM »
Probably his Lib Path settings in VS.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5788
  • Yes Pinky, Do-more will control the world!
Re: VISUAL C ETHERCMM
« Reply #9 on: August 09, 2011, 09:24:59 PM »
Wouldn't the linker complain about not finding the lib, rather than fussing about the unresolved?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

JMB

  • Jr. Member
  • **
  • Posts: 15
Re: VISUAL C ETHERCMM
« Reply #10 on: August 09, 2011, 09:51:00 PM »
When I went to test your alternate function, I first commented out the #include<mmsystem.h> file to make sure that it would locate all of the timeGetTime calls.  The Linker error that I got was something like that.  Maybe he has a problem with that file.

Looking at the actual header again, it seems that if MMNOTIMER is defined, the function declaration will be omitted by the preprocessor.  Perhaps he has that or WIN32_LEAN_AND_MEAN defined (which will apparently also cause problems with this function).

Jacob
Jacob Berghofer
Robotics and Automation Engineering Technologist
E-One Moli Energy (Canada) Ltd, Maple Ridge, B.C.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5788
  • Yes Pinky, Do-more will control the world!
Re: VISUAL C ETHERCMM
« Reply #11 on: August 09, 2011, 10:07:33 PM »
The old timeGetTime() function was part of the multi-media library from forever ago. It was particularly important when trying to do precision timing with comm protocols when GetTickCount() worked at the 55ms system tick. I think GetTickCount() may actually be millisecond resolution on modern Windows OSes, so it could be used as a direct replacement.

In some cases (mostly for profiling) we have needed better precision than 1ms. The function I posted can be adjusted to give you whatever resolution, just change the multiplier. QueryPerformanceCounter() returns a very high precision hardware counter which is driven by the system clock, and QueryPerformanceFrequency() gives you the number of counts per second, so dividing the count by the frequency gives you a second tick. Multiply by a 1000000 before dividing and you get microseconds and 1000 will give you milliseconds. We haven't used timeGetTime() for a long time, we just haven't touched up the SDK examples.

Perhaps once we get this new CPU and programming software shipped, we should go back and update the SDK. Probably could do it in a day. If only I had a free day... ::)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

JMB

  • Jr. Member
  • **
  • Posts: 15
Re: VISUAL C ETHERCMM
« Reply #12 on: August 10, 2011, 01:55:15 AM »
Yeah, that mythical free day.  I think it's an urban legend, the kind of thing that only happens to someone's brother's cousin's roommate's nephew.

I'd be happy to contribute updated versions of the SDK samples similar to the changes that I did to get the EtherCCM sample to compile and update to a newer version of VS.  Unfortunately I don't have hardware except for ECOMs so someone else would have to test them.  Have you ever considered a pure .NET port of the SDK itself?  There seems to be a fair number of people creating wrappers for it.

Jacob
Jacob Berghofer
Robotics and Automation Engineering Technologist
E-One Moli Energy (Canada) Ltd, Maple Ridge, B.C.

chrisatwan

  • Full Member
  • ***
  • Posts: 30
Re: VISUAL C ETHERCMM
« Reply #13 on: August 10, 2011, 09:04:21 AM »
JMB,

I have everything set up to test if you want to share code.

Thanks,
Christopher

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5788
  • Yes Pinky, Do-more will control the world!
Re: VISUAL C ETHERCMM
« Reply #14 on: August 10, 2011, 11:38:32 AM »
I'd be happy to contribute updated versions of the SDK samples similar to the changes that I did to get the EtherCCM sample to compile and update to a newer version of VS.

What's there is actually a bit of stone soup already, so yes, we'd be happy to look at whatever you have.

Quote
Have you ever considered a pure .NET port of the SDK itself?  There seems to be a fair number of people creating wrappers for it.

We haven't really considered anything at all for a long time, but only because we've been focused elsewhere. Once MX is shipped, I wouldn't mind completely revamping the SDK, including appropriate MX samples. Were we to do so, I would think that .NET would be an obvious goal, being the spiritual successor to all things VB.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO