Skip to content

ReadBytes() method cannot detect :WAVeform:DATA eof correctly #12

@luyi1888

Description

@luyi1888

0x0a in the chunks end is not sufficient to detected eof. It will return in the middle of data.

Device: Siglent SDS 2000X Plus

https://siglentna.com/wp-content/uploads/dlm_uploads/2024/03/ProgrammingGuide_EN11F.pdf
Image

I make the following changes to workaround this bug. Maybe read length from header will be better idea.

ScpiConnectionExtensions.cs

public static async Task<byte[]> ReadBytes(this IScpiConnection conn, int numOfBytesToRead, int specialTimeout = 0, CancellationToken cancellationToken = default)
{
    var result = new MemoryStream();
    var buffer = new byte[conn.DefaultBufferSize];

    ReadResult chunk;
    while (result.Length < numOfBytesToRead)
    {
        chunk = await conn.Read(buffer, buffer.Length, specialTimeout, cancellationToken);
        result.Write(buffer, 0, chunk.Length);
    }

    return result.ToArray();
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions