CySmart DLL Import @Unity

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
TaDa_1407706
Level 2
Level 2

Is there anyone can import CySmart DLL into Unity Project???

I know it's a little bit Unity's issue, but I also want to get your advice.

At first, I've already confirmed that below DLLs work well by C# WPF project.

(I confirmed that it open CY5677 dongle's comm port without problem.)

  • cybleautobase.dll
  • cyblecommonbase.dll
  • cybledonglecommunicator.dll

Then I bring those DLLs into Unity project, and confirmed "there is no error message".

But the problem is that DLL doesn't work at all.(TryGetCySmartDongleCommunicator Function returns NULL)

I've tried to modify below configuration options, but the situation doesn't change.

(Build Setting→Player Setting→Other Setting →Configuration)

  • Runtime version : 4.0 -> 3.5 (rebuild but NG)
  • Scripting Backend : Mono->IL2CPP ( Still NG)
  • Api Compatibility : 4.0 -> 2.0 (still NG)

=======

My Environment

  • Unity 2018.4.16f1 personal
  • Microsoft Visual Studio Community 2019 Version 16.5.1
  • Windows 10 1903

DLL information (confirmed at VS2019's property window)

  • Version : 1.3.0.8
  • Runtime Version: v2.0.50727

=======

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using CySmart.Common.Base.Compatibility.Net20;
  5. using CySmart.DongleCommunicator.API;
  6. using System.Runtime.InteropServices.ComTypes;
  7. public class BLErx : MonoBehaviour{
  8.     CyDongleInfo DongleInfo;
  9.     CySmartDongleMgr DongleManager;
  10.     ICySmartDongleCommunicator Comm;
  11.     public void StartBLE()
  12.     {
  13.      DongleInfo = new CyDongleInfo("COMxx", CyDongleInfo.CySmartDongleType.CY5677);
  14.      DongleManager = CySmartDongleMgr.GetInstance();
  15.      CyApiErr err = DongleManager.TryGetCySmartDongleCommunicator(DongleInfo, out Comm);
  16.      if (err.IsOk)
  17.      {
  18.          Debug.Log("OK");
  19.      }
  20.      else
  21.      {
  22.          Debug.Log("NG");
  23.      }
  24. }
  25. }
0 Likes
1 Solution
TaDa_1407706
Level 2
Level 2

I modified PSoC 4 dongle firmware which output UART (P1[4],P1[5]).

In this case, I don't need to use DLL file such as cybleautobase.dll,

so I can use Serial Port as usual, and confirmed BLE information.

I think this is one of the solution for Unity reciving BLE from Cypress Dongle.

========

I tried bellow cases, but in all cases,"NotSupportedException: System.IO.Ports.SerialPort" happen.

Case 1. Unity 2018 Mono    .Net 4.x

Case 2. Unity 2018 IL2CPP  .Net 4.x

Case 3. Unity 2018 Mono    .Net standoard 2.x

Case 4. Unity 2018 IL2CPP  .Net standoard 2.x

(When switching .NET 3.5 Equivalent environment, the situation doesn't change)

Case 5. Unity 2019 Mono    .Net 4.x

Case 6. Unity 2019 IL2CPP  .Net 4.x

Case 7. Unity 2019 Mono    .Net standoard 2.x

Case 8. Unity 2019 IL2CPP  .Net standoard 2.x

========

Thanks

View solution in original post

0 Likes
7 Replies
TaDa_1407706
Level 2
Level 2

I think this QA is similar, but this problem is NOT Win or Mac problem,

since I confirmed that I could connect CY5677 dongle when using C# WPF project.

Unity testing in OSX doesn't connect to Pioneer 4.

0 Likes
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

I don't think anyone has tried importing the DLLs into a Unity project other than the one thread you mentioned.  We have tested the application to work in Visual Studio as a WPF project. I'm inclined to believe this will work even in Unity if the target platform is set to Windows in the Build Settings.

After you added the code, did you see any error in the console when you run the application? Can you please share the Player.log file which gets generated at this path: "C:\Users\<user_name>\AppData\LocalLow\<company_name>\<app_name>"

I tried creating an application to test it at my end. I need to set up my environment correctly, I see some DLLs like XInput1_3.dll and IL2CPP missing. I will try to get those fixed.

Meanwhile, please attach the log so that we can get more insight into this. Looking forward to your reply

Regards,

Dheeraj

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Dheeraj,

Thank you for your comment.

First, I upload WPF project.

This project is very simple (just checking port open)

and I confirmed this work well.

And what I want to do is to import this function to Unity.

(off course I'd like to receive BLE data at Unity but DLL import check is the first. )

Next I'll upload Unity project and player.log file.

Thanks.

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Dheeraj,

I upload three files.

1. Unity Project (This project is also very simple (just checking dongle port open, same as WPF project. ))

2. Editor log file

3. Player log file

It seems that  output_log.txt shows "PlatformNotSupportedException" was happened.

0 Likes
lock attach
Attachments are accessible only for community members.

I built this project as a UWP(x86, IL2cpp, Api compatibility: DotNet2.0)

After building at Visual Studio 2019 (Release x86,Local computer),

I found "NotSupportedException: System.IO.Ports.SerialPort" shown as attached file.

So I'm pretty sure that this problem is caused by SerialPort Dll.

0 Likes

I found this mentioned in the Unity Forums. Can you try the solution mentioned here: System.IO.Ports missing for Unity with .NET 4.x - Unity Answers ?

Regards,

Dheeraj

0 Likes
TaDa_1407706
Level 2
Level 2

I modified PSoC 4 dongle firmware which output UART (P1[4],P1[5]).

In this case, I don't need to use DLL file such as cybleautobase.dll,

so I can use Serial Port as usual, and confirmed BLE information.

I think this is one of the solution for Unity reciving BLE from Cypress Dongle.

========

I tried bellow cases, but in all cases,"NotSupportedException: System.IO.Ports.SerialPort" happen.

Case 1. Unity 2018 Mono    .Net 4.x

Case 2. Unity 2018 IL2CPP  .Net 4.x

Case 3. Unity 2018 Mono    .Net standoard 2.x

Case 4. Unity 2018 IL2CPP  .Net standoard 2.x

(When switching .NET 3.5 Equivalent environment, the situation doesn't change)

Case 5. Unity 2019 Mono    .Net 4.x

Case 6. Unity 2019 IL2CPP  .Net 4.x

Case 7. Unity 2019 Mono    .Net standoard 2.x

Case 8. Unity 2019 IL2CPP  .Net standoard 2.x

========

Thanks

0 Likes