Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Tue Nov 21, 2017 3:54 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Aug 19, 2009 3:47 am 
Offline

Joined: Wed Aug 19, 2009 3:43 am
Posts: 7
Is there a unique hardware identifier available to code that we can use to identify each Treq device in our system?

The obvious candidate is the Ethernet MAC address. However, if we purchase M4s with the 3rd USB port option instead of the Ethernet interface, will the device still have a MAC address?

Thanks,
Kenn


Top
 Profile  
 
PostPosted: Wed Aug 19, 2009 7:34 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
Here is a link to some sample code for retrieving a unique identifier with the .NET Compact Framework:
http://msdn.microsoft.com/en-us/library/aa446562.aspx

I tested it on the TREQ-M4 with a couple minor syntax changes. Here's the code.

Code:
        private static Int32 FILE_DEVICE_HAL = 0x00000101;
        private static Int32 FILE_ANY_ACCESS = 0x0;
        private static Int32 METHOD_BUFFERED = 0x0;

        private static Int32 IOCTL_HAL_GET_DEVICEID =
            ((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14)
            | ((21) << 2) | (METHOD_BUFFERED);

        [DllImport("coredll.dll")]
        private static extern bool KernelIoControl(Int32 IoControlCode,
            IntPtr InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer,
            Int32 OutputBufferSize, ref Int32 BytesReturned);

        private static string GetDeviceID()
        {
            byte[] OutputBuffer = new byte[256];
            Int32 OutputBufferSize, BytesReturned;
            OutputBufferSize = OutputBuffer.Length;
            BytesReturned = 0;

            // Call KernelIoControl passing the previously defined
            // IOCTL_HAL_GET_DEVICEID parameter
            // We don’t need to pass any input buffers to this call
            // so InputBuffer and InputBufferSize are set to their null
            // values
            bool retVal = KernelIoControl(IOCTL_HAL_GET_DEVICEID,
                IntPtr.Zero,
                0,
                OutputBuffer,
                OutputBufferSize,
                ref BytesReturned);

            // If the request failed, exit the method now
            if (retVal == false) {
                return null;
            }

            // Examine the OutputBuffer byte array to find the start of the
            // Preset ID and Platform ID, as well as the size of the
            // PlatformID.
            // PresetIDOffset – The number of bytes the preset ID is offset
            //                  from the beginning of the structure
            // PlatformIDOffset - The number of bytes the platform ID is
            //                    offset from the beginning of the structure
            // PlatformIDSize - The number of bytes used to store the
            //                  platform ID
            // Use BitConverter.ToInt32() to convert from byte[] to int
            Int32 PresetIDOffset = BitConverter.ToInt32(OutputBuffer, 4);
            Int32 PlatformIDOffset = BitConverter.ToInt32(OutputBuffer, 0xc);
            Int32 PlatformIDSize = BitConverter.ToInt32(OutputBuffer, 0x10);

            // Convert the Preset ID segments into a string so they can be
            // displayed easily.
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("{0:X8}-{1:X4}-{2:X4}-{3:X4}-",
                 BitConverter.ToInt32(OutputBuffer, PresetIDOffset),
                 BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 4),
                 BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 6),
                 BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 8)));

            // Break the Platform ID down into 2-digit hexadecimal numbers
            // and append them to the Preset ID. This will result in a
            // string-formatted Device ID
            for (int i = PlatformIDOffset;
                 i < PlatformIDOffset + PlatformIDSize;
                 i++) {
                sb.Append(String.Format("{0:X2}", OutputBuffer[i]));
            }

            // return the Device ID string
            return sb.ToString();
        }

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
PostPosted: Wed Aug 19, 2009 8:20 am 
Offline

Joined: Wed Aug 19, 2009 3:43 am
Posts: 7
Thanks. That's exactly what I was looking for.

Later,
Kenn


Top
 Profile  
 
PostPosted: Wed Mar 02, 2011 11:16 am 
Offline

Joined: Wed Aug 19, 2009 3:43 am
Posts: 7
I've just tried this on a TREQ-M4 model 3456R and it returns the unicode string "TREQ-M4" as the PresetID and the ANSI string "TreqM4-QSI54321" as the platform ID.

Is the TREQ's serial number (as per the label on the rear, e.g. 94902965W049) embedded anywhere within the device and readable by software?

Thanks,
Kenn


Top
 Profile  
 
PostPosted: Fri Mar 18, 2011 10:49 am 
Offline
User avatar

Joined: Thu Jan 14, 2010 10:20 am
Posts: 38
Kenn,

Having the TREQ's serial number embedded into the device is a build option that must be requested before production.

If your solution requires that your current fielded units need the serial number programmed into them, please contact your QSI sales representative for more details.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group