Mini-Maestro and Unity3D compatibility issue

Hello, I’m a long-time Maestro user and lover. I want to use a chain of Maestros together with the wonderful Unity3D application, which uses Mono, based on .net 2.0, for its scripting. I am using Windows 7 64-bit and Unity 4.0 along with a single 24-channel Maestro for now. But I can’t get Unity to talk to the COM ports. Here is the appropriate JavaScript code snippet:

private var paryPortName = new Array();
private var pprtMaestro : System.IO.Ports.SerialPort;
// These namespace references are at the top, above this code snippet:
// import 	System;
// import	System.IO.Ports;

function Start () {
	var L : int;
	var strPortName : String;
	// Iterate through the available ports and save their names in an array
	for (var s : String in System.IO.Ports.SerialPort.GetPortNames()){paryPortName.Push(s);}
   	// Iterate through the array displaing the names of all available ports
   	for (L = 0; L < paryPortName.length; L++){print("L=" + L + " name=" + paryPortName[L]);}
	// Get the name of the Pololu control (NOT TTL) port, always the second to the last the way I use my system.
	strPortName = paryPortName[paryPortName.length - 2];
	// Create the port reference and assign the name, baud rate, parity, data bits and stop bit.
	pprtMaestro = new System.IO.Ports.SerialPort(strPortName, 115200, Parity.None, 8, StopBits.One);
	// Be ready for trouble
	try {
		// Open the port
	catch(err) {
		print("Port is not open  " + err);

I get the catch phrase which says, “Port is not open.” The appended error says, “System.IO.IOException: The port ‘COM23’ does not exist.” COM23 is exactly the name that I see in the Device Manager for the Control port (COM24 is the TTL port). So GetPortName gets the name, but IOException says it doesn’t exist, even though I use the name via variable without any chance of corrupting the name string (and every reasonable permutation to get it to work, like hard-coding “COM23”). Maybe there is some implied portion of the name or path I am supposed to be adding (I have tried ‘/dev/COM23’ because I saw a hint that might work). Maybe .net 2.0 doesn’t like COM port names higher than 4 or 5. Does anyone have any insight about this kind of problem? By the way, Unity converts my optional JavaScript scripts to C++, just as it does Unity’s optional C# or Boo scripts, so going with the C# equivalent of my script doesn’t make any difference-- I’ve tried it. I’ve had great success communicating with my chained Maestros using, UscCmd works with AutoHotKey just great, I can talk to the current Maestro using the Control Center, and Unity 4.0 is just exquisite and modern except for Mono’s use of .net 2.0. However, I need some of Unity’s matchless 3D features so I need to get it to talk to the Control COM port. Can you help me? Thanks so much! Loren

Hello, Loren.

Sometimes the USB-to-Serial driver usbser.sys gets into a bad state and you just have to reset it. Have you tried unplugging the Maestro, closing all programs that might be using a COM port, and plugging it back in? Have you tried rebooting the computer?

It shouldn’t be necessary but you could also try entering “USBSER000” as the COM port name if the Maestro is the only device plugged in that is using usbser.sys.

Another thing to try is to add \\.\ to the beginning of the COM port name. To write that properly as a string in your source code, you probably have to escape the slashes, so you would write it as "\\\\.\\COM23".


David!!! You pegged it first try! Well done!! The \\\\.\\COM2 trick did the job! I understand that translates to \\.\, but what does it mean? And how did you know about that? I’d like to know so I can pass it on, or, even better, take the time you probably don’t have to expand on the topic for the benefit of my fellow Maestro-users so they can learn how a .net application could come to require that special prefix or path designation or whatever it is.
Anyway, great job. That should be useful information to a lot of people.


Actually I am not sure what it means. I just know that if you want to open a COM port above COM9 with the CreateFile function you need that prefix. You can also open other objects like \\.\USBSER000 this way and the WinObj utility can provide a list of those objects.


\\.\ is the “device” namespace in the Windows NT file system.

You can start here:
although this part of Windows really lacks good overview – AFAICT, you’re supposed to go take a class to learn how to do Windows device drivers :-/


I am also a Unity developer and would like to know if the Mini Maestro library is written in native .Net C# code.
The documentation gives a hint here by mentioning “C# .NET class libraries that enable native USB communication with the Maestro (written in C#).”
That sounds like the library is not originally written in C/C++ and only wrapped with C#. Right ?

But does this really mean that I can just use this library in Unity and it works ?
Would be great if someone could confirm this before I have to buy and test it myself…



In the sentence you quoted, the word “native” only refers to the native USB interface, which is part of the Maestro’s firmware. It does not refer to the code used to communicate with that interface.

I am not sure what you mean by “native .Net C# code”. All of the libraries in the Pololu USB SDK that are used to communicate with the Maestro are written in C# (not C/C++). One of those libraries, UsbWrapper, has platform-specific code for talking to USB devices, so I would need to know what operating systems you want your program to support before I can give advice about whether the libraries will work for you.

Please let me know if you have any further questions.



Thank you for your answer and sorry for the confusion.

I am basically looking for a C# .Net library I can drag & drop into my Unity project on Windows 10 64-bit to communicate with a Mini Maestro. First step would be to control a RC servo from within Unity.

Where exactly can I find this .dll ?


The Pololu USB SDK contains C# libraries that can control the Maestro over USB on Windows, using its native USB interface. After you download the SDK, you can find those libraries in the following folders inside the SDK:

  • Maestro\Usc
  • Maestro\Sequencer
  • Maestro\Bytecode
  • UsbWrapper_Windows

The Usc library is the main library that you should use to talk to the Maestro. The other libraries are its dependencies. The SDK contains several example projects that show how to use Usc.

I am not familiar with Unity and I cannot say how easy it will be to integrate these libraries with it. If you have any trouble, I recommend reading the README.txt file at the top level of the SDK and following the instructions in the “Compiling Maestro C# code in Windows” section, which explain how to compile the Maestro examples with Visual Studio. Doing that will probably help you understand the libraries a little bit better.