Skip to content

Commit

Permalink
Fixed wrong condition for POOR_SIGNAL warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Chica committed Jan 12, 2023
1 parent 48aedfb commit 9542908
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions neuropy3/neuropy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,34 @@ def run(self):
while not self.flag.is_set():
self._read_packet()

def _read(self, bytes=1):
def _read(self, n_bytes=1):
"""Reads bytes from bluetooth socket
:param bytes: Number of bytes to read
:type bytes: int, optional. Default: 1
:param n_bytes: Number of bytes to read
:type n_bytes: int, optional. Default: 1
:return: A bytearray read from bluetooth socket
:rtype: bytearray"""
self.socket.settimeout(5)
try:
return self.socket.recv(bytes)
return self.socket.recv(n_bytes)
except bluetooth.btcommon.BluetoothError:
ut.log('error', "Bluetooth timed out. Check headset is on.",
self.verbose)
sys.exit(1)

def _b2i(self, value, bytes=1):
def _b2i(self, value, n_bytes=1):
"""Converts bytes to integer
Depending of the size of the bytes, integer can be signed
or unsigned. More info in thinkgear communications protocol
:param value: Value to be converted
:type value: bytearray
:param bytes: Number of bytes to be converted
:type bytes: int, optional. Allowed: 1, 2, 4. Default: 1
:param n_bytes: Number of bytes to be converted
:type n_bytes: int, optional. Allowed: 1, 2, 4. Default: 1
:return: Value after converting bytearray
:rtype: int"""
vtype = '>B'
if bytes == 2:
if n_bytes == 2:
vtype = '>h'
elif bytes == 4:
elif n_bytes == 4:
vtype = '>I'
return struct.unpack(vtype, value)[0]

Expand Down Expand Up @@ -159,7 +159,7 @@ def _read_packet(self):
"MindWave electrodes are not in "
"contact with your skin.",
self.verbose)
elif value > ut.NO_CONTACT:
elif value:
ut.log('warn',
"MindWave poor signal detected. "
"Check electrodes or "
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

setup(
name='neuropy3',
version='1.0.2',
version='1.0.3',
description=('Python3 library to read data from '
'Neurosky Mindwave Mobile 2 in linux.'),
author='Sergio Chica',
Expand Down

0 comments on commit 9542908

Please sign in to comment.