Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by lam meng chun · Jun 06, 2011 at 03:16 PM · dll

Unity 3d C++ run time error

BIRDREADING bird_data;

i receive c++ runtime error when my code include birdreading variable.Anyone have any idea about it.

Microsoft Visual C++ Runtime Library Runtime Error!

Program:C:\Program Files\Unity\Editor\Unity.exe

This application has requested the Runtime to terminate it in an unusual way.

please contact the application's support team for more information.

below is my code

 using UnityEngine;
 
 using System.Collections;
 
 using System;
 
 using System.Collections.Generic;
 
 using System.ComponentModel;
 
 using System.Text;
 
 using System.Runtime.InteropServices;
 
 using System.Linq;
 
 using System.Threading;
 
 
 
 public class DLLImportFOB : MonoBehaviour
 
 {
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 1)]
 
     public struct BIRDPOSITION
 
     {
 
         public short nX;            // x-coordinate
 
         public short nY;            // y-coordinate
 
         public short nZ;            // z-coordinate
 
     }
 
 
 
 
 
     // Bird angles structure
 
     [StructLayout(LayoutKind.Sequential, Pack = 1)]
 
     public struct BIRDANGLES
 
     {
 
         public short nAzimuth;    // azimuth angle
 
         public short nElevation;    // elevation angle
 
         public short nRoll;        // roll angle
 
     }
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 1)]
 
     public struct BIRDMATRIX
 
     {
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
 
         public short[,] n;
 
 
 
 
 
     }
 
 
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 1)]
 
     public struct BIRDQUATERNION
 
     {
 
         public short nQ0;        // q0
 
         public short nQ1;        // q1
 
         public short nQ2;        // q2
 
         public short nQ3;        // q3
 
     }
 
 
 
 
 
 
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 0)]
 
     public struct BIRDREADING
 
     {
 
         public BIRDPOSITION position;    // position of receiver
 
         public BIRDANGLES angles;        // orientation of receiver, as angles
 
         public BIRDMATRIX matrix;        // orientation of receiver, as matrix
 
         public BIRDQUATERNION quaternion; // orientation of receiver, as quaternion
 
         public ushort wButtons;    // button states
 
     }
 
 
 
 
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 0)]
 
     public struct BIRDFRAME
 
     {
 
         public uint dwTime;        // time at which readings were taken, in msecs
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 127)]
 
         public BIRDREADING[] readings; // reading from each bird
 
     }
 
 
 
 
 
 
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 0)]
 
     public struct BIRDSYSTEMCONFIG
 
     {
 
         public byte bySystemStatus;
 
         public byte byError;
 
         public byte byNumDevices;
 
         public byte byNumServers;
 
         public byte byXmtrNum;
 
         public ushort wXtalSpeed;
 
         public double dMeasurementRate;
 
         public byte byChassisNum;
 
         public byte byNumChassisDevices;
 
         public byte byFirstDeviceNum;
 
         public ushort wSoftwareRev;
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 127)]
 
         public byte[] byFlockStatus;
 
     }
 
 
 
     [StructLayout(LayoutKind.Sequential, Pack = 0)]
 
     public struct BIRDDEVICECONFIG
 
     {
 
         public byte byStatus;            // device status (see bird device status bits, above)
 
         public byte byID;                // device ID code (see bird device ID's, above)
 
         public ushort wSoftwareRev;        // software revision of device
 
         public byte byError;            // error code flagged by device
 
         public byte bySetup;            // setup information (see bird device setup bits, above)
 
         public byte byDataFormat;        // data format (see bird data formats, above)
 
         public byte byReportRate;        // rate of data reporting, in units of frames
 
         public ushort wScaling;            // full scale measurement, in inches
 
         public byte byHemisphere;        // hemisphere of operation (see bird hemisphere codes, above)
 
         public byte byDeviceNum;        // bird number
 
         public byte byXmtrType;            // transmitter type (see bird transmitter type bits, above)
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
 
         public ushort[] wAlphaMin;        // filter constants (see Birdnet3 Protocol pp.26-27 for values)
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
 
         public ushort[] wAlphaMax;        // filter constants (see Birdnet3 Protocol pp.26-27 for values)
 
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
 
         public ushort[] wVM;                // filter constants (see Birdnet3 Protocol pp.26-27 for values)
 
         BIRDANGLES anglesReferenceFrame;    // reference frame of bird readings
 
         BIRDANGLES anglesAngleAlign;        // alignment of bird readings
 
     }
 
 
 
 
 
 
 
     enum GroupModeSettings
 
     {
 
         //    GMS_DEFAULT,                        // driver will determine whether or not to use RS232 group mode
 
         GMS_GROUP_MODE_NEVER,                    // RS232 group mode will never be used
 
         GMS_GROUP_MODE_ALWAYS,                    // RS232 group mode will always be used
 
         NUM_GROUP_MODE_SETTINGS
 
     };
 
 
 
 
 
 
 
 
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdRS232GroupModeEnabled(int GroupID);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdShutDown(int GroupID);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdRS232WakeUp(int nGroupID, Boolean bStandAlone, int nNumDevices,
 
                            ushort[] pwComport, uint dwBaudRate, uint dwReadTimeout,
 
                            uint dwWriteTimeout, int nGroupMode);
 
 
 
     [DllImport(@"bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdGetSystemConfig(int nGroupID, ref BIRDSYSTEMCONFIG psyscfg, bool bGetDriverCopy);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdSetSystemConfig(int nGroupID, ref BIRDSYSTEMCONFIG psyscfg);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdGetFastDeviceConfig(int nGroupID, int nDeviceNum, ref BIRDDEVICECONFIG pdevcfg);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdStartFrameStream(int nGroupID);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdGetMostRecentFrame(int nGroupID, ref BIRDFRAME pframe);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdFrameReady(int nGroupID);
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern string birdGetErrorMessage();
 
 
 
 
 
     [DllImport(@"Bird.dll", CallingConvention = CallingConvention.Cdecl)]
 
     public static extern bool birdStopFrameStream(int nGroupID);
 
 
 
 
 
     const int GROUP_ID = 1;
 
     const int READ_TIMEOUT = 2000;
 
     const int WRITE_TIMEOUT = 2000;
 
     const int BAUD_RATE = 115200;
 
     const double measurement_rate = 103.3;
 
 
 
     int DEVCOUNT = 2;
 
     string fobStatus = "Not Wake Up";
 
     string bird1PosX="0", bird1PosY="0", bird1PosZ="0";
 
     string bird2PosX="0", bird2PosY="0", bird2PosZ="0";
 
    
 
     bool birdIsWakeUp = false;
 
     bool getPosition = false;
 
      ushort[] COM_port = new ushort[] { 0, 19, 0, 0, 0 };
 
 
 
     BIRDSYSTEMCONFIG sysconfig;
 
     BIRDDEVICECONFIG[] devconfig = new BIRDDEVICECONFIG[5];
 
     BIRDFRAME frame;
 
 
 
     double[] pos = new double[3];
 
     double[] ang = new double[3];
 
     //BIRDREADING bird_data;
 
 
 
 
 
 
 
     // Use this for initialization
 
     void Start()
 
     {
 
 
 
     }
 
 
 
     // Update is called once per frame
 
     void Update()
 
     {
 
 
 
         if (getPosition)
 
         {
 
             int i = 1;
 
             birdStartFrameStream(GROUP_ID);
 
 
 
             if (birdFrameReady(GROUP_ID))
 
             {
 
                 birdGetMostRecentFrame(GROUP_ID, ref frame);
 
                
 
 
 
                 for (i = 1; i < DEVCOUNT + 1; i++)
 
                 {
 
 
 
                     bird_data = frame.readings[i];
 
 
 
                     string x, y, z;
 
                     x = (bird_data.position.nX * 36 / 32767.0).ToString();
 
                     y = (bird_data.position.nY * 36 / 32767.0).ToString();
 
                     z = (bird_data.position.nZ * 36 / 32767.0).ToString();
 
 
 
                     switch (i)
 
                     {
 
 
 
                         case 1:
 
                             bird1PosX =  x;
 
                             bird1PosY =  y;
 
                             bird1PosZ =  z;
 
                             break;
 
                         case 2:
 
                             bird2PosX =  x;
 
                             bird2PosY =  y;
 
                             bird2PosZ =  z;
 
 
 
                             break;
 
                         default:
 
                             bird1PosX = "Error";
 
                             bird1PosY = "Error";
 
                             bird1PosZ = "Error";
 
 
 
                             bird2PosX = "Error";
 
                             bird2PosY = "Error";
 
                             bird2PosZ = "Error";
 
                             break;
 
                     }
 
 
 
                 }
 
             }
 
               
 
       
 
         }
 
 
 
     }
 
     void OnGUI()
 
     {
 
 
 
 
 
         GUI.Box(new Rect(800, 50, 250, 25), "Status FOB:" + fobStatus);
 
         GUI.Box(new Rect(800, 90, 50, 25), "Bird 1 Position X:" + bird1PosX);
 
         GUI.Box(new Rect(900, 90, 50, 25), "Bird 1 Position Y:" + bird1PosY);
 
         GUI.Box(new Rect(1000, 90, 50, 25), "Bird 1 Position Z:" + bird1PosZ);
 
         
 
         GUI.Box(new Rect(800, 140, 50, 25), "Bird 2 Position X:" + bird2PosX);
 
         GUI.Box(new Rect(900, 140, 50, 25), "Bird 2 Position Y:" + bird2PosY);
 
         GUI.Box(new Rect(1000, 140, 50, 25), "Bird 2 Position Z:" + bird2PosZ);
 
 
 
         if ((GUI.Button(new Rect(800, 10, 250, 25), "Connect Flock Of Bird")))
 
         {
 
 
 
             if (!birdRS232WakeUp(GROUP_ID, false, DEVCOUNT, COM_port, BAUD_RATE, READ_TIMEOUT, WRITE_TIMEOUT, 1))
 
             {
 
                 fobStatus = "Failde to wake up FOB";
 
 
 
             }
 
             else
 
             {
 
                 fobStatus = "Complete wake up FOB";
 
                 birdIsWakeUp = true;
 
 
 
             }
 
         }
 
 
 
         if (birdIsWakeUp)
 
         {
 
             if ((GUI.Button(new Rect(800, 10, 250, 25), "Connect Flock Of Bird")))
 
             {
 
                 getPosition = true;
 
             }
 
         }
 
 
 
 
 
 
 
 
 
     }
 
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PaulUsul · Jun 06, 2011 at 03:41 PM 0
Share

Debug through it to see exactly what line it crashes at, then post the external code. It's definitely in the dll code

avatar image lam meng chun · Jun 07, 2011 at 02:01 AM 0
Share

this code is work in visual studio, btw i try insert breakpoint in my code it is never stop in the line of the code, it is direct show me the runtime error after i click play.

avatar image fab_garcia lam meng chun · Mar 11, 2016 at 04:28 PM 0
Share

Did you find the error? Can you send me more informations about that? Thank you.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Finding the Problematic dll in "Extracting Referenced dlls Failed" (Unity5) 1 Answer

Problem Exporting WebApp because of extra dll's 0 Answers

merged DLL not working 0 Answers

How to integrate C++ dll file into unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges