MacUSBMBS confusion

Good afternoon

As using the normal serial device can’t filter out based on vid/pid I try now with MacUSBMBS from the MBS USB plugin.

The device I have is a so called BattLab-One which has an FTDI USB2UART chip on board.

For example a simple ‘j’ sent down to it returns back following hex data when using Python3 serial module:

013b
00e1
00b5
00ae
00aa
00a8
00a5
00a1
0082
00fa
0104
0118
0118
0330
0334
036b

In Xojo I use this for sending which works fine as I can see that it for example can switch voltage on the output:

dim s as string = TextField1.text
m.WriteRaw(2, s)

But when reading back with:

m.ReadRaw(1,1024)

I always get:

0160

Only in rare cases I get:

0160
0334
036B
03B6
013B
00E1
00B5
00AE
00AA
00A8
00A5
00A1
0082
00FA
0104
0118
0118
0330
0334
036B
03B6

Where the data is exact as in Python starting from the 4th line…

Ah seems to work better now (o;
Shouldn’t have used the clear pipe command before sending/receiving…

Still wondering why it always prepends 0x0160 for every ReadRaw command though it doesn’t return anything:

sent: h
Returned 2 bytes
Hex Read: 0160

The device doesn’t respond at all when sending “h” (power supply on).

Also not sure if to use MacUSBMBS at all…as there is no function/method to choose which interface to use when several devices have the same VID/PID/Name…so useless…

Weird…

Seems FTDI devices are sending back their PID as the first two bytes in ReadRaw…regardless if anything was sent or not.

So 0x0160 is PID 0x6001 for the FTDI UART chips…
Prolific chips don’t send the PID prepended.

Just have to figure out how to initialize the Prolific ones to the correct UART settings…
but I guess libUSB seems to be the last resort then…

Well, you are basically running a raw connection and get the serial protocol.
So when you send our plugin doesn’t package it for you and when you receive, we don’t unpack it.
You may lookup the protocol details and you may find what is the meaning of the packages.

Some byte is probably the start of the package, some the end. Somewhere is the length of data and in the middle should be the data.

Hello Christian

Already switching to libUSB as it supports more than one device with same VID/PID/Name (o;

Bildschirmfoto 2022-04-05 um 15.49.33

Just have to figure out how I could package it with universal libusb-1.0.0.dylib…

1 Like

You can usually just include the dylib in the frameworks folder of your app.

Well yes…that works for me on my Mac Mini M1 machine…

Question is how I can package it with an universal usblib…but then again…Intel is soon dead on Mac…and Apple will buy Advanced RISC machines after the dead NVidia deal :wink:

BTW: Are there any licensing issues with bundling libusb?

There are still something like 100 million Intel Macs out there with your customers.

libusb is LGPL, so you can include a dylib within the app and load it at runtime.

But question still remains (o;

How to build an universal libusb on M1 to package with an universal build…

You checked our libraries folder?

https://www.monkeybreadsoftware.de/xojo/download/plugin/Libs/

Oh, I See. That one is not yet ported to Apple Silicon.

Maybe you can just get one via homebrew pre-built and copy it.

So I need separate builds for Intel and M1?

Or is there a way to check during runtime on which silicon it runs?

No, you can lipo them together.

See
https://www.manpagez.com/man/1/lipo/