saleae / SaleaeSocketApi

The Saleae software includes a socket based interface for scripting and automation applications.
73 stars 35 forks source link

Issues with the SocketAPI's ExportData2 method #6

Closed martonmiklos closed 6 years ago

martonmiklos commented 6 years ago

Hi guys,

I have came across a strange thing when implemented the SocketAPI for Qt.

I have tried to export the captured data to VCD on specific channels.

I have implemented the ExportData2 method according to the C# implementation so my command sent to the Logic server was the following:

EXPORT_DATA2, /tmp/out.vcd, SPECIFIC_CHANNELS, 0 DIGITAL, 1 DIGITAL, ALL_TIME, VCD

However the command line output of the Logic suggested me that I am missing a DIGITAL_ONLY/ANALOG_ONLY/ANALOG_AND_DIGITAL between the SPECIFIC_CHANNELS and the 0 DIGITAL part.

By checking the C# code: https://github.com/saleae/SaleaeSocketApi/blob/master/SaleaeSocketApi/SocketApi.cs#L484

As you can see above this field is only added to the command if mixed mode is selected so I think the C# implementation has issue with this configuration too.

Marcus10110 commented 6 years ago

Sorry for the trouble!

That extra parameter is only required when the capture contains a mix of analog and digital channels.

If your capture only contains digital channels, then the export command you have works fine.

However, if you capture a mix of analog and digital channels, the extra parameter (DIGITAL_ONLY, ANALOG_ONLY, ANALOG_AND_DIGITAL) is required.

The correct command becomes:

EXPORT_DATA2, C:\Users\Mark\Desktop\ExportUnitTest\vcd_mixed_mode, SPECIFIC_CHANNELS, DIGITAL_ONLY, 0 DIGITAL, 1 DIGITAL, ALL_TIME, VCD

This is annoying because The export command now needs to know more details about the capture in order to work. Unfortunately the export system was designed before we added analog support, and analog support was added without redesigning the export system. This resulted in it being harder to handle.EXPORT_DATA2 was added because of a few flaws in EXPORT_DATA That made it impossible to properly use without breaking backward compatibility.

You will notice that in the C# code, there are two extra parameters to ExportData2, capture_contains_digital_channels and capture_contains_analog_channels. These flags tell the API implementation if it needs to compose the export command differently, depending on if the capture was a mix of digital and analog channels, or just digital or just analog.

Let me know if you have any more questions about this.

martonmiklos commented 6 years ago

Thank you very much Marcus for the explanation!

I might suggest to add some documentation about the capture_contains_digital_channels and the capture_contains_analog_channels parameters to make it straightforward that they refer to the captured data not to the data to be exported.

Marcus10110 commented 6 years ago

good idea, this is fixed in the latest commit, through comments on ExportData2