mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Update code to conform to the newer version of pylint available in
ubuntu-22.04, with few exceptions:
- disabled `import-outside-toplevel` for `main()` in
`jerry_client.py`
- disabled `consider-using-with` for the logfile of `TestSuite` in
`test262-harness.py` as using `with` is not practical in that case
Update test262-harness.py to use argparse instead of the now deprecated
optparse
Rename variables in jerry_client_main.py that redefined python builtins
or shadowed variables from an outer scope
Update python files to use f-stirngs
Add minimum python versions (3.6 and 3.8) to the CI jobs: without it the
default python version did not support the `with` statement for
`subprocess.Popen` used in `build.py` on macos, or in some cases f-stirngs
Remove `from __future__` imports that are no-ops in python 3
Remove shebang from non executable files
Re-enable most pylint checkers, except `missing-docstring`
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
# Copyright JS Foundation and other contributors, http://js.foundation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import select
|
|
import serial
|
|
|
|
class Serial:
|
|
""" Create a new socket using the given address family, socket type and protocol number. """
|
|
def __init__(self, serial_config):
|
|
config = serial_config.split(',')
|
|
config_size = len(config)
|
|
|
|
port = config[0] if config_size > 0 else "/dev/ttyUSB0"
|
|
baudrate = config[1] if config_size > 1 else 115200
|
|
bytesize = int(config[2]) if config_size > 2 else 8
|
|
parity = config[3] if config_size > 3 else 'N'
|
|
stopbits = int(config[4]) if config_size > 4 else 1
|
|
|
|
self.ser = serial.Serial(port=port, baudrate=baudrate, parity=parity,
|
|
stopbits=stopbits, bytesize=bytesize, timeout=1)
|
|
|
|
def connect(self):
|
|
""" Connect to the server, write a 'c' to the serial port """
|
|
self.send_data('c')
|
|
|
|
def close(self):
|
|
"""" close the serial port. """
|
|
self.ser.close()
|
|
|
|
def receive_data(self, max_size=1024):
|
|
""" The maximum amount of data to be received at once is specified by max_size. """
|
|
return self.ser.read(max_size)
|
|
|
|
def send_data(self, data):
|
|
""" Write data to the serial port. """
|
|
return self.ser.write(data)
|
|
|
|
def ready(self):
|
|
""" Monitor the file descriptor. """
|
|
result = select.select([self.ser.fileno()], [], [], 0)[0]
|
|
|
|
return self.ser.fileno() in result
|