Bug 1640 - Error while saving: invalid argument
Summary: Error while saving: invalid argument
Alias: None
Product: PulseView
Classification: Unclassified
Component: File handling (show other bugs)
Version: 0.5.0
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
Depends on:
Reported: 2020-11-17 11:21 CET by marko
Modified: 2023-09-12 00:34 CEST (History)
3 users (show)

screenshot (4.31 KB, image/png)
2020-11-17 11:21 CET, marko
file from PulseView 4.1 (3.33 KB, application/zip)
2020-11-17 12:24 CET, marko

Note You need to log in before you can comment on or make changes to this bug.
Description marko 2020-11-17 11:21:36 CET
Created attachment 701 [details]

I am using PulseView 4.1 on my Raspberry Pi (4.2 is unfortunately not available).

I am using Pulseview 5.0 on my PC (Windows).  I am using it to do further analysis of the files obtained on Raspberry Pi.

I can open the file and analyse data without any problem.  However, when I want to do save the file on Windows, I get error Error while saving: invalid argument.
Comment 1 Soeren Apel 2020-11-17 12:08:08 CET
Hello, I'm suspecting an issue with file names or directory names. Does a directory or file name contain language-specific characters?
Comment 2 marko 2020-11-17 12:24:57 CET
Created attachment 702 [details]
file from PulseView 4.1
Comment 3 marko 2020-11-17 12:25:30 CET
No.  I have shared a sample file that creates problems.
Comment 4 Soeren Apel 2020-11-17 14:35:58 CET
sr: [00:25.914708] output/srzip: Unexpected unit size, discarding logic data.

Okay, so the problem is the metadata says
total probes=16
but also
which is not possible.

Which device driver did you use to capture the data? My knee-jerk reaction is to say that the driver is broken and needs fixing. At the same time, it might also be nice to provide a generic solution that "soft"-fixes this - e.g. by limiting the probe count to the maximum that the unit size permits.
Comment 5 marko 2020-11-17 15:19:04 CET
I am using Cypress FX2 board on Raspberry Pi 3.

Yes, there are 16 probes, of which I use only 8.  I have no idea what is unitsize and I do not changing this setting.

By the way, despite the fact that Cypress supports frequencies up to 24MHz, I can only use up to 8MHz, because in other cases PulseView it stops recording data after about a second regardless of number of samples.
Comment 6 marko 2020-11-17 15:20:44 CET
I have installed sigrok-firmware-fx2lafw on my Raspberry Pi 3, if it helps.
Comment 7 Soeren Apel 2020-11-17 15:37:24 CET
What's the VID:PID pair of your USB device before and after firmware upload?

Closing PV, unplugging the FX2 and plugging it back in gives you the "before" pair - starting PV gives you the "after" pair as PV uploads the firmware to the FX2.
Comment 8 marko 2020-11-17 15:47:55 CET
It is the same, 04b4:8613.
Comment 9 marko 2020-11-19 15:45:50 CET
So is there any workaround for this problem before the bug is identified and removed?  For example to edit *.sr file so that the metadata are correct?
Comment 10 Soeren Apel 2020-11-19 16:19:14 CET
As a workaround, you can open the .sr file in any zip archiver of your choice (it's a zip file with .sr instead of .zip) and edit the metadata file. In there, you'll see a probe count of 16 and a unit size of 1.

If you're acquiring 16-bit data, probe count must be 16 and unit size must be 2.
If you're acquiting 8-bit data, probe count must be 8 and unit size must be 1.
Comment 11 marko 2020-11-19 19:20:25 CET
Thanks.  That was very helpful.

I hope you will identify and correct the bug soon.
Comment 12 mycodeisbeautiful 2021-12-12 17:02:15 CET
I'm seeing the same issue, using fx2lafw 04B4:8613 on Windows 10.
(fx2lafw:conn=3.2 - Cypress FX2 [S/N: Cypress FX2] with 16 channels)

In PulseView it will capture and display data correctly, but cannot save as .sr file.  It errors out with "Failed to save session. Error while saving: invalid argument"

At the command line, I get:
> sigrok-cli -d fx2lafw -c samplerate=24mhz --samples 500m -o filename.sr -C D0=CS,D1=MISO,D2=WP,D4=MOSI,D5=CLK,D6=HOLD

sr: output/srzip: Unexpected unit size, discarding logic data.
sr: output/srzip: Unexpected unit size, discarding logic data.
sr: output/srzip: Unexpected unit size, discarding logic data.

using sigrok-cli 0.8.0-git-7ce834c
Comment 13 Jernej Jakob 2023-09-12 00:34:37 CEST
Still present on master. The info above about editing the metadata file inside the .sr zip archive doesn't work since only total probes is present, unitsize is not. If I change probe number to 8 and put the edited metadata back into the .sr zip file, once I try to save again in pulseview, it throws the same error again. Do I need to exit the current session and open the edited .sr file as a new session?