Page 1 of 1

ASIGetSerialNumber(camID)

Posted: Tue Sep 10, 2019 5:35 pm
by grayarea56@gmail.com
Hi All,
I'm new to the forum, this is my first post.
I'm trying to connect to multiple camera's, and sometimes they come up with different camera ID numbers, based on the order of plugging in the USB ports.
I need to read the serial numbers.
I see a post that references ASIGetSerialNumber
I'm using C#, and importing the DLL(s), either the 32 bit or the 64 bit.
Everything has been working fine.
I upgraded to the very latest development, but the documentation says nothing about ASIGetSerialNumber.
Also, when I call the dll with entry point as ASIGetSerialNumber, it completely restarts my application, not even an exception.
I'm using the very latest devopment dll's version:
ASI_Windows_SDK_V1.14.0715
Dan Gray
siderealtechnology.com

Re: ASIGetSerialNumber(camID)

Posted: Mon Sep 16, 2019 1:15 am
by chad
Hi Dan,
Can you show me the codes which calls GetSerialNumber?
Usually, we used the following code to call it (it is a C++ code):

ASI_SN ASI_sn = {0};
ASIGetSerialNumber(iSelectedID, &ASI_sn);
sn_temp.Format(" SN:%02x%02x %02x%02x %02x%02x %02x%02x", ASI_sn.id[0], ASI_sn.id[1], ASI_sn.id[2], ASI_sn.id[3], ASI_sn.id[4], ASI_sn.id[5], ASI_sn.id[6], ASI_sn.id[7]);

Thanks
Chad

Re: ASIGetSerialNumber(camID)

Posted: Mon Sep 30, 2019 8:37 pm
by grayarea56@gmail.com
Thanks for your reply, looking at your code snippet, I think I need the definition of the ASI_SN structure.
It's not in the document I have.

Can you post the ASI_SN structure definition for me? Thanks.
Dan.

P.S.
For your information, here's my code snippets as trying now, after seeing your example, I see why it crashes.

here's my DLL import Section, one for 32 bit, and the other for 64 bit:

[DllImport("ASICamera2.dll", EntryPoint = "ASIGetSerialNumber", CallingConvention = CallingConvention.Cdecl)]
private static extern string ASIGetSerialNumber32(int iCameraID);

[DllImport("ASICamera2_x64.dll", EntryPoint = "ASIGetSerialNumber", CallingConvention = CallingConvention.Cdecl)]
private static extern string ASIGetSerialNumber64(int iCameraID);

Here' the calling code:
internal static string ASIGetSerialNumber(int iCameraID)
{
if (IntPtr.Size == 8) //If 32 bit
return ASIGetSerialNumber64(iCameraID);
return ASIGetSerialNumber32(iCameraID);
}

And finally, here's how I call it in the main program.
string camSerNum = ASICameraDll2.ASIGetSerialNumber(camID);

Dan Gray

Re: ASIGetSerialNumber(camID)

Posted: Tue Oct 08, 2019 2:54 am
by chad
Hi Dan,
you can find it in the header file.
typedef struct _ASI_ID{
unsigned char id[8];
}ASI_ID;

typedef ASI_ID ASI_SN;

And it is defined as this.
Thanks
Chad