first serial com test

This commit is contained in:
GHOSCHT 2020-07-30 21:19:49 +02:00
parent 2c30301744
commit e492618b06

View file

@ -1,5 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import SerialPort from 'serialport';
export default class Login extends Component { export default class Login extends Component {
static propTypes = { static propTypes = {
@ -24,11 +25,17 @@ export default class Login extends Component {
}; };
render() { render() {
const port = new SerialPort('COM3');
const triggerOn = () => {
port.write('on');
};
const triggerOff = () => {
port.write('off');
};
return ( return (
<div> <div>
<h2>Login</h2> <button onClick={triggerOn}>ON</button>
<input onChange={this.handleChange} type="text" value={this.state.username} /> <button onClick={triggerOff}>OFF</button>
<button onClick={this.handleLogin}>Log In</button>
</div> </div>
); );
} }