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:
My HTML:
<ion-button expand="block" (click)="beginReading()">ReadSerial</ion-button>
<p> WHAT I'M READING IS: {{SERIALREAD}}</p>
And in my .ts I have((sorry for the spanish beforehand)):
checkearSerial() {
this.serial.requestPermission().then(() => {
this.serial.open({
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 0,
dtr: false,
rts: false,
sleepOnPause: false
}).then(() => {
this.ESTADOCONSERIAL = 'conexion realizada'
console.log('Serial connection opened');
this.localNotifications.schedule({
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"
});
}
And:
empezarLectura() {
if (this.lector) {
this.lector.unsubscribe();
}
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:
-AD:30
-ETRO:12
-003
-VELOCI
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