Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
Or, use your gamerDNA username: (more...)
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-23-2007, 06:55 PM   #1 (permalink)
Alarion
Registered User
 
Join Date: Oct 2003
Location: Hampton Roads, VA
Posts: 71
+0 Internets
C++ in Windows CE

This is a problem that has been bugging be for the last few days at work. Figured I would post here on the off chance someone here has experience in this area.

Here's the basic scenario:
MFC based C++ application, running on an Intermec handheld computer (Windows CE 4.2) with an ARMv4 processor. Program originally developed for DOS in C, I have ported to this new environment. This device has a barcode scanner built in.

The program in question is basically a data entry application, used for tracking assets (missiles, magazines, grenades, etc) as they are shipped around from place to place.

So, the user clicks on of many buttons on the main screen, and gets presented with a series of input prompts. Currently, they get one prompt at a time. I have this implemented in a dialog window that pops up with an input field and a few buttons. The user can either scan a barcode or type the data in. Barcode input is handled in a seperate thread that spawns when each input window is shown, and is destroyed in the dialog's destructor.

Now the problem is, under a certain scenario, I get a "datatype misalignment" error and the program crashes - when a barcode is scanned in. It only happens when I follow a certain test/execution path however, the debugger seems to indicate the problem is with the hardware vendor supplied library.

Seeing as how all my development before this was on the x86 platform, I never had to deal with this issue. It seems it has to do with some pointer operations, based on results returned from google.

Just curious if anyone here has developed for windows ce, in C++, targetting an ARM processor and encountered this issue. Anything in particular I should be looking for? I have spent about three days now trying to track this thing down. I guess my next step will be to continually pester the vendor for some debug versions of their libraries :-/

My initial thought is maybe the scanner threads are not being closed properly - and indeed a test snippet I have in the program seems to indicate the # of threads increases by one at each input prompt... so maybe with x number of threads open, fighting for the scanner resource, it ends up at an invalid pointer?
__________________
Dinak :: 70 Shaman :: Thorium Brotherhood <Reckless Ascension> (WoW)
Dinaek :: T3 Ironbreaker :: Bretonnia

Last edited by Alarion : 03-23-2007 at 06:57 PM.
Alarion is offline   Reply With Quote
Old 03-23-2007, 09:05 PM   #2 (permalink)
Phelps McManus
I'm dangerous!
 
Join Date: Jan 2002
Location: Atlanta
Posts: 891
I haven't programmed for CE, but a "data misalignment" sounds like you are violating a word boundary or something. Maybe putting a 4-byte int into a 2-byte short. I figure the compiler would pick that up though...

With C++ it could be something more heinous like word packing in your structs. What do you know! I did a google on struct word alignment and an article on your ARM processor came up near the top.

ARM/NetWinder Structure Alignment FAQ

Here is some more generic info on that sort of problem.

Data structure alignment - Wikipedia, the free encyclopedia

It is actually a really common problem when you port code from one architecture to another. Some compilers have different defaults on whether they use 1-byte or 4-byte (or maybe even 2-byte) word boundaries.

I did a port from XP to HP-UX of some ANSI C code once and had to use some compiler directive (#progma or something, I can't remember) to force it to use 1-byte word boundaries.

If that IS your problem then you are in luck, as it should be easy to fix. Much easier than bad vendor libraries anyway. Good luck!
Phelps McManus is offline   Reply With Quote
Old 03-24-2007, 08:41 AM   #3 (permalink)
Alarion
Registered User
 
Join Date: Oct 2003
Location: Hampton Roads, VA
Posts: 71
+0 Internets
thanks. In all my googling, I didn't come across those links. :-/

In the links I did encounter, indeed I saw mentions of it being a problem with the packed structures. Since the error is being encountered in the vendor library, I assumed it might be the structure that is passed to the vendor API for reading the barcode (which ends up holding the barcode data, the size of the data read, and a few other things like symbology type, etc)

Thanks for taking the time to google and provide the links. I was apparently searching on the wrong keywords (namely "CE datatype misalignment")
__________________
Dinak :: 70 Shaman :: Thorium Brotherhood <Reckless Ascension> (WoW)
Dinaek :: T3 Ironbreaker :: Bretonnia
Alarion is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 12:59 AM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6