Skip to content

Commit

Permalink
Problem with terminal input solved (I think so)
Browse files Browse the repository at this point in the history
  • Loading branch information
agomezgar authored Dec 3, 2023
1 parent 0433c15 commit cf95f39
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions term.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
var { ipcRenderer } = require("electron")
var remote = require('electron')
var remote = require('@electron/remote')
var fs = require('fs')
const {BrowserWindow} = require('electron').remote
const {SerialPort} = require("serialport")
const { ReadlineParser } = require('@serialport/parser-readline')
//var line = SerialPort.parsers.Readline;
var moniteur = document.getElementById('fenetre_term')
var baud = parseInt(localStorage.getItem("baudrate"))
var com = localStorage.getItem("com")
var s_p = new SerialPort({path: com, baudRate:baud})

//const {BrowserWindow} = require('electron').remote
window.addEventListener('load', function load(event) {
var win = remote;
var connexion = false;
Expand All @@ -24,13 +32,10 @@ window.addEventListener('load', function load(event) {
window.close()
}
document.getElementById('btn_connect').onclick = function(event) {
const SerialPort = require("serialport")
var line = SerialPort.parsers.Readline;
var moniteur = document.getElementById('fenetre_term')
var baud = parseInt(localStorage.getItem("baudrate"))
var com = localStorage.getItem("com")
var s_p = new SerialPort(com,{baudRate:baud, autoOpen:false})
var parser = s_p.pipe(new line({ delimiter: '\n' }))

//const port = new SerialPort({ path: '/dev/ROBOT', baudRate: 14400 })
const parser = s_p.pipe(new ReadlineParser({ delimiter: '\r\n' }))
//var parser = s_p.pipe(new line({ delimiter: '\n' }))
if (connexion){
document.getElementById('btn_connect').innerHTML="<span class='fa fa-play'> Arrancar</span>"
document.getElementById('btn_envoi').disabled=true
Expand Down

0 comments on commit cf95f39

Please sign in to comment.