Mac SDK on Apple Silicon with Swift streaming crash?

Post your C and C++ discussions here
Post Reply
dognotdog
Newbie
Posts: 0
Joined: Sun Jan 16, 2022 11:51 pm

Mac SDK on Apple Silicon with Swift streaming crash?

Post by dognotdog »

I'm trying to get a Swift Mac app to talk to my 3405D MSO scope with the SDK v10.7.21.227, on Apple Silicon. The initial connection seems fine, eg. the device is detected and can be queried for properties. Unfortunately, I cannot seem to get the streaming to work, as it produces an EXC_BAD_ACCESS somewhere in the PicoSDK libraries, I presume when the driver tries to trigger the streaming callback. Unfortunately the SDKs contain no debug symbols, so I could not trace it further.

I managed to get the SDK example C code compiled as x86_64 (so is the app), and it works fine, so I assume it's either some bug with the buffers (I do 2 separate setBuffer calls instead of setBuffers), or the Swift runtime not being able to cope with the callback mechanism, possibly buffer size?. I see nothing obviously wrong anywhere, though, and the callback is empty (but never gets called anyway).

Any ideas how to proceed? Is it possible to get a PicoSDK with debug symbols, or the sources to the drivers?

PS: SDK compiled with following commands, after symlinking relevant SDK libs to /usr/local/lib

Code: Select all

DYLD_LIBRARY_PATH=/usr/local/lib CFLAGS=/Library/Frameworks/PicoSDK.framework/Headers arch -x86_64 ./autoconf.sh
DYLD_LIBRARY_PATH=/usr/local/lib CFLAGS=/Library/Frameworks/PicoSDK.framework/Headers arch -x86_64 make
Attachments
crash-streaming.png

dognotdog
Newbie
Posts: 0
Joined: Sun Jan 16, 2022 11:51 pm

Re: Mac SDK on Apple Silicon with Swift streaming crash?

Post by dognotdog »

As a follow up, I figured out that the crash likes to happen with fast data rates, but streaming does kind of work with lower sampling rates.

However, one odd thing I found is that the streaming callback will indicate there being more data than the buffer is long, how is one supposed to handle that case? Does data wrap around in the buffer?

Martyn
Site Admin
Site Admin
Posts: 4483
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Mac SDK on Apple Silicon with Swift streaming crash?

Post by Martyn »

Can you post your code so that we can see how you have set up the buffers.

There is a double buffering arrangement, a circular raw data buffer in the driver related to the overviewBufferSize used in the RunStreaming call, and the buffers setup by the SetDataBuffer(s) calls that are used to transfer data to the application. It shouldn't be possible for the driver to report that it has more data than the overviewBufferSize, if this buffer becomes full data is held in the devices memory until this has been cleared.
Martyn
Technical Support Manager

dognotdog
Newbie
Posts: 0
Joined: Sun Jan 16, 2022 11:51 pm

Re: Mac SDK on Apple Silicon with Swift streaming crash?

Post by dognotdog »

Thanks, I did figure out that there was a typo in the buffer setup, leading to the wrong size being computed. 🤦‍♂️

Post Reply