Coder Social home page Coder Social logo

Comments (2)

ctacke avatar ctacke commented on July 24, 2024

Cannot reproduce.

The above is unclear exactly how to repro, but I used the following.

On the meadow (F7FeatherV2)

var port = Device
    .PlatformOS
    .GetSerialPortName("com4")
    ?.CreateSerialPort(19200, 8, Parity.None, StopBits.One, 2048)
    ?? throw new System.Exception("com4 not found");

var buffer = new byte[4096];

port.Open();

while (true)
{
    var read = port.Read(buffer, 0, buffer.Length);

    if (read == 0)
    {
        Thread.Sleep(1000);
        continue;
    }

    Resolver.Log.Info($"rx {read:N4} bytes");
    Resolver.Log.Info($"  {Encoding.ASCII.GetString(buffer, 0, read)}");
}

on a PC

var port = new SerialPort("COM5", 19200);
port.Open();

var message = "On the 24th of February, 1815, the look-out at Notre-Dame de la Garde signalled the three-master, the Pharaon from Smyrna, Trieste, and Naples";
var messages = message.Split(' ', StringSplitOptions.RemoveEmptyEntries);

while (true)
{
    for (var i = 0; i < messages.Length; i++)
    {
        var data = Encoding.ASCII.GetBytes(messages[i]);
        port.Write(data, 0, data.Length);
        Thread.Sleep(2000);
    }
}

And it worked as expected.

from meadow.core.

UeberDaniel avatar UeberDaniel commented on July 24, 2024

@ctacke, i tested your code it with my testfile and HTerm, it produces the same error, the problem is the length of the datastream. You tested it with a message ~150 byte, but that is not enough to reproduce this error.

I used this to produce the datastream and the testfile:

            byte[] prefix = new byte[] { 0x01, 0x10, 0x02, 0x20, 0x04, 0x40, 0x08, 0x80 };
            byte[] buffer = new byte[1032];

            for(int i = 0; i < buffer.Length; i++)
            {
                buffer[i++] = 0xFF;
                buffer[i] = 0x00;
            }

            for (int j = 0; j < prefix.Length; j++)
            {
                buffer[j] = prefix[j];
            }
            File.WriteAllBytes(@"D:\file.txt", buffer);
            _serialPort.Write(buffer, 0, buffer.Length);

Screenshot 2023-07-26 185132

Here is my generated testfile for HTerm: file.txt

from meadow.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.