问题描述
仅需一些背景知识,我就使用Linux Mint(32位)中的原始数据流。来自我的库,该库从数据流文件中读取24位块。
Just a bit of background, I'm working with a raw data stream in Linux Mint (32 bit). It's from my library ruby-buzz, which reads 24-bit lumps out of the data stream file.
我刚刚用32位Linux Mint重新安装了笔记本电脑,突然我看到了错误 Errno :: EINVAL :无效的参数@ io_fread
。
I've just re-installed my laptop with Linux Mint, 32-bit, and suddenly I'm seeing the error Errno::EINVAL: Invalid argument @ io_fread
.
ajfaraday@squishy ~ $ sudo chmod 777 /dev/input/by-id/*
ajfaraday@squishy ~ $ irb
2.2.1 :001 > path = '/dev/input/by-id/usb-Logitech_Logitech_Buzz_tm__Controller_V1-event-if00'
=> "/dev/input/by-id/usb-Logitech_Logitech_Buzz_tm__Controller_V1-event-if00"
2.2.1 :002 > f = File.open(path)
=> #<File:/dev/input/by-id/usb-Logitech_Logitech_Buzz_tm__Controller_V1-event-if00>
2.2.1 :003 > f.read(24)
Errno::EINVAL: Invalid argument @ io_fread - /dev/input/by-id/usb-Logitech_Logitech_Buzz_tm__Controller_V1-event-if00
from (irb):3:in `read'
from (irb):3
from /home/ajfaraday/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'
2.2.1 :004 > f.read(32)
=> "\xAB>xW\x0E\xDC\x00\x00\x01\x00\xC0\x02\x01\x00\x00\x00\xAB>xW\x0E\xDC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
在同一系统上,使用相同的输入设备,我在
我不知道为什么以前可以使用 tail -f
来查看来自终端的原始数据流的原因,并且为什么我以前能够使用 file.read(24)
从ruby抓取这24位块。包括安装Mint。
I don't know why I've previously been fine to use tail -f
to watch a raw data stream from the terminal, and why I've previously been able to use file.read(24)
to grab that 24 bit chunk from ruby. Including on an install of Mint. But now I'm unable to do either.
推荐答案
我不完全理解我找到的解决方案,但是可能
I don't fully understand the solution I found, but it will probably help anyone faced with the same problem, so here goes.
这似乎是Linux Mint的32位体系结构的结果,不允许使用 file.read
方法可使用非2的幂的参数(例如8、16、32)。我不知道为什么。
It appears to be a consequence of the 32-bit architecture of Linux Mint that it will not allow the file.read
method to work with an argument that's not a power of 2 (e.g. 8, 16, 32). I do not know why this is.
但是,使用64位版本的Mint重新安装,可以像我以前在KDE安装中看到的那样工作(回想起来,可能是64位架构。
However, re-installing using the 64-bit version of Mint, this works as I was previously seeing on my KDE install (which, in retrospect, was probably a 64-bit architecture).
这篇关于从红宝石读取USB输入流。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!