Adding support for RM2

This commit is contained in:
Emanuele 2021-01-02 23:28:59 +01:00
parent ac56d4e998
commit 693e709a98
2 changed files with 19 additions and 18 deletions

View file

@ -201,22 +201,24 @@ class rMViewApp(QApplication):
# cat /sys/devices/soc0/machine -> reMarkable 1.x
_,out,_ = ssh.exec_command("cat /sys/devices/soc0/machine")
rmv = out.read().decode("utf-8")
ver = re.fullmatch(r"reMarkable (\d+)\..*\n", rmv)
if ver is None or ver[1] != "1":
log.error("Device is unsupported: '%s' [%s]", rmv, ver[1] if ver else "unknown device")
version = re.fullmatch(r"reMarkable (\d+)\..*\n", rmv)
if version is None or version[1] not in ["1", "2"]:
log.error("Device is unsupported: '%s' [%s]", rmv, version[1] if version else "unknown device")
QMessageBox.critical(None, "Unsupported device", 'The detected device is %s.\nrmView currently only supports reMarkable 1.' % rmv)
self.quit()
return
version = int(version[1])
# check needed files are in place
_,out,_ = ssh.exec_command("[ -x $HOME/rM-vnc-server ] && [ -e $HOME/mxc_epdc_fb_damage.ko ]")
_,out,_ = ssh.exec_command("[ -x $HOME/rM-vnc-server-standalone ]")
if out.channel.recv_exit_status() != 0:
mbox = QMessageBox(QMessageBox.NoIcon, 'Missing components', 'Your reMarkable is missing some needed components.')
icon = QPixmap(":/assets/problem.svg")
icon.setDevicePixelRatio(self.devicePixelRatio())
mbox.setIconPixmap(icon)
mbox.setInformativeText(
"To work properly, rmView needs the rM-vnc-server and mxc_epdc_fb_damage.ko files "\
"To work properly, rmView needs the rM-vnc-server-standalone program "\
"to be installed on your tablet.\n"\
"You can install them manually, or let rmView do the work for you by pressing 'Auto Install' below.\n\n"\
"If you are unsure, please consult the documentation.")
@ -232,15 +234,11 @@ class rMViewApp(QApplication):
try:
sftp = ssh.open_sftp()
from stat import S_IXUSR
fo = QFile(':bin/rM-vnc-server')
fo = QFile(':bin/rM%d-vnc-server-standalone' % version)
fo.open(QIODevice.ReadOnly)
sftp.putfo(fo, 'rM-vnc-server')
fo.close()
sftp.chmod('rM-vnc-server', S_IXUSR)
fo = QFile(':bin/mxc_epdc_fb_damage.ko')
fo.open(QIODevice.ReadOnly)
sftp.putfo(fo, 'mxc_epdc_fb_damage.ko')
sftp.putfo(fo, 'rM-vnc-server-standalone')
fo.close()
sftp.chmod('rM-vnc-server-standalone', S_IXUSR)
log.info("Installation successful!")
except Exception as e:
log.error('%s %s', type(e), e)
@ -263,7 +261,7 @@ class rMViewApp(QApplication):
self.fbworker.signals.onFatalError.connect(self.frameError)
self.threadpool.start(self.fbworker)
self.penworker = PointerWorker(ssh)
self.penworker = PointerWorker(ssh, path="/dev/input/event%d" % (version-1))
self.threadpool.start(self.penworker)
self.pen = self.viewer.scene.addEllipse(0,0,self.pen_size,self.pen_size,
pen=QPen(QColor('white')),

View file

@ -41,8 +41,10 @@ class RFB(RFBClient):
self.setEncodings([
HEXTILE_ENCODING,
CORRE_ENCODING,
PSEUDO_CURSOR_ENCODING,
RRE_ENCODING,
RAW_ENCODING ])
time.sleep(.1) # get first image without artifacts
self.framebufferUpdateRequest()
def sendPassword(self, password):
@ -89,11 +91,11 @@ class FrameBufferWorker(QRunnable):
log.info("Stopping framebuffer thread...")
reactor.callFromThread(reactor.stop)
try:
self.ssh.exec_command("killall rM-vnc-server", timeout=3)
self.ssh.exec_command("killall rM-vnc-server-standalone", timeout=3)
except Exception as e:
log.warning("VNC could not be stopped on the reMarkable.")
log.warning("Although this is not a big problem, it may consume some resources until you restart the tablet.")
log.warning("You can manually terminate it by running `ssh %s killall rM-vnc-server`.", self.ssh.hostname)
log.warning("You can manually terminate it by running `ssh %s killall rM-vnc-server-standalone`.", self.ssh.hostname)
log.error(e)
log.info("Framebuffer thread stopped")
@ -102,7 +104,7 @@ class FrameBufferWorker(QRunnable):
try:
_,out,_ = self.ssh.exec_command("/sbin/insmod $HOME/mxc_epdc_fb_damage.ko")
log.debug("Insmod returned %d", out.channel.recv_exit_status())
_,_,out = self.ssh.exec_command("$HOME/rM-vnc-server")
_,_,out = self.ssh.exec_command("$HOME/rM-vnc-server-standalone")
log.info(next(out))
except Exception as e:
self.signals.onFatalError.emit(e)
@ -133,8 +135,9 @@ class PointerWorker(QRunnable):
_stop = False
def __init__(self, ssh, threshold=1000):
def __init__(self, ssh, path="/dev/input/event0", threshold=1000):
super(PointerWorker, self).__init__()
self.event = path
self.ssh = ssh
self.threshold = threshold
self.signals = PWSignals()
@ -145,7 +148,7 @@ class PointerWorker(QRunnable):
@pyqtSlot()
def run(self):
penkill, penstream, _ = self.ssh.exec_command('cat /dev/input/event0 & { read ; kill %1; }')
penkill, penstream, _ = self.ssh.exec_command('cat %s & { read ; kill %%1; }' % self.event)
self._penkill = penkill
new_x = new_y = False
state = LIFTED