USB serial not showing all the data

Hello everyone from the forums! I am having extreme issues with this as I’ve spent an entire day browsing for solutions and I’ve come up with nothing that can solve my issue, I’m conecting my tablet through USB serial cable, and the thing that’s sending data to me is sending (working on Ionic 4):

Now, when I try to retrieve it from my code like this:


    <ion-button expand="block" (click)="beginReading()">ReadSerial</ion-button>

And in my .ts I have((sorry for the spanish beforehand)):

  checkearSerial() {
    this.serial.requestPermission().then(() => {{
        baudRate: 9600,
        dataBits: 8,
        stopBits: 1,
        parity: 0,
        dtr: false,
        rts: false,
        sleepOnPause: false
      }).then(() => {
        this.ESTADOCONSERIAL = 'conexion realizada'
        console.log('Serial connection opened');
          id: 2,
          title: 'ALERTA',
          text: 'USB ENCONTRADO',
          data: { mydata: 'BLAHBLAH' },
          trigger: { in: 1, unit: ELocalNotificationTriggerUnit.SECOND },
          foreground: true
    }).catch((error: any) => {
      this.ERRORSERIAL = error
      this.ESTADOCONSERIAL = "no conectado"


empezarLectura() {
    if (this.lector) {
    else {
      this.lector = timer(1000, 1000).subscribe(() => {
        this.serial.registerReadCallback().subscribe(val => {
          var view = new Uint8Array(val);
          var str = String.fromCharCode.apply(null, view);
          this.SERIALREAD = str

I’ve come into the necessity to use the subscribeable variable “lector” as the registerCallback function kinda just does the thing once and then just stops.

Anyways, my problem is that when I display the data, it is -NEVER- complete, taking the example image from before, it would print stuff like:

ETC. I NEVER get the entire data… please, help me out with this, I’m dying at work ;-; I can provide additional information if asked

I would suggest undoing this. It’s not sustainable and is going to just obscure the core issue here, which (I believe) is protocol design.

From the POV of the serial driver (and the corresponding cordova plugin that fills this role in your app), neither “the data” nor “complete” mean anything, so you have to take responsibility for managing those concepts.

Think of yourself as a book editor, and the device connected to the serial port as one of your authors. This author sends you whatever words they’ve written whenever they’ve written them. Sometimes it’s seven chapters at once, sometimes it’s four pages, sometimes it’s half a sentence or even just part of a single word. That’s how the data is going to come across to your handler. Your code is responsible for buffering it, stitching it together, determining what constitutes a “packet”, and therefore what “the data” and “complete” mean.

Given the sample data you posted, my first instinct would be to declare line feeds to be delimiters and “a line” to represent the smallest “packet”. I would then probably chunk three lines into a single object with velocidad, odometro, and sensor properties.

1 Like

Thank you! I’ll try that!

That’s worthy suggestions