Linux上的Cygnal Integrated Products串口(Cygnal Integrated Products serial port on Linux)
我有一个红外测温仪,它通过USB在虚拟串口上运行,我试图在Debian Linux上使用它。 不幸的是,系统没有枚举
/dev/ttyUSB
设备。这是设备的
dmesg
:usb 5-1: new full-speed USB device number 3 using uhci_hcd usb 5-1: New USB device found, idVendor=10c4, idProduct=834b usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 5-1: Product: Infrared Online Sensor Adapter usb 5-1: Manufacturer: Silicon Labs usb 5-1: SerialNumber: CT00092755
这是
lsusb -v
:Bus 005 Device 003: ID 10c4:834b Cygnal Integrated Products, Inc. Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x10c4 Cygnal Integrated Products, Inc. idProduct 0x834b bcdDevice 1.00 iManufacturer 1 iProduct 2 iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 2 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0
我怎样才能使这个工作,所以我可以用串口连接它?
I have an infrared thermometer which operates on a virtual serial port over USB, which I am trying to use on Debian Linux. Unfortunately, the system does not enumerate a
/dev/ttyUSB
device.Here is the
dmesg
for the device:usb 5-1: new full-speed USB device number 3 using uhci_hcd usb 5-1: New USB device found, idVendor=10c4, idProduct=834b usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 5-1: Product: Infrared Online Sensor Adapter usb 5-1: Manufacturer: Silicon Labs usb 5-1: SerialNumber: CT00092755
And here is the
lsusb -v
:Bus 005 Device 003: ID 10c4:834b Cygnal Integrated Products, Inc. Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x10c4 Cygnal Integrated Products, Inc. idProduct 0x834b bcdDevice 1.00 iManufacturer 1 iProduct 2 iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 2 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0
How can I get this working, so I can connect to it with the serial port?
原文:https://stackoverflow.com/questions/38963029
最满意答案
您的代码中存在多个语法问题。
这段代码适合我。
library("parallel") accCost_wrap <- function(x){accCost2(h16,x)} #Instead of including h16 in the parRapply function, #just get it in the node environment cl = makeCluster(3) clusterExport(cl, c("h16", "accCost2")) #B will be "sent" to the nodes through the parRapply function. clusterEvalQ(cl, {library(gdistance)}) #raster is a dependency of gdistance, so no need to include raster here. pp <- parRapply(cl, x=B, FUN=accCost_wrap) stopCluster(cl) connections <- data.frame(from = rep(1:nrow(B), each = nrow(B)), to = rep(1:nrow(B), nrow(B)), dist = as.vector(pp))
您的accCost版本确实比gdistance中的版本更快。 您的版本会省略检查以查看您的积分是否在过渡层范围内。 谨慎行事。
(您可以通过将单元格编号作为输入来使您的功能更快。此外,从每个节点发回大量数据似乎效率不高。)
There are several syntax issues in your code.
This code works for me.
library("parallel") accCost_wrap <- function(x){accCost2(h16,x)} #Instead of including h16 in the parRapply function, #just get it in the node environment cl = makeCluster(3) clusterExport(cl, c("h16", "accCost2")) #B will be "sent" to the nodes through the parRapply function. clusterEvalQ(cl, {library(gdistance)}) #raster is a dependency of gdistance, so no need to include raster here. pp <- parRapply(cl, x=B, FUN=accCost_wrap) stopCluster(cl) connections <- data.frame(from = rep(1:nrow(B), each = nrow(B)), to = rep(1:nrow(B), nrow(B)), dist = as.vector(pp))
Your version of accCost is indeed faster than the version in gdistance. Your version omits the checks to see if your points are within the extent of your transition layer. Proceed with caution.
(You could make your function even faster by taking the cell numbers as input. Also, sending so much data back from each node does not seem very efficient.)
相关问答
更多-
我写了S4(仍在进行中)可以在这里找到: http : //adv-r.had.co.nz/S4.html My write up of S4 (still in progress) is available here: http://adv-r.had.co.nz/S4.html
-
R中S4对象的总和(sum of S4 objects in R)[2021-07-18]
这里是一个例子: setClass("yyy", representation(v="numeric")) setMethod("+", signature(e1 = "yyy", e2 = "yyy"), function (e1, e2) e1@v + e2@v) setMethod("+", signature(e1 = "yyy", e2 = "numeric"), function (e1, e2) e1@v + e2) 然后, > y1 <- new("yyy", v = 1) > y2 < ... -
如何访问S4对象的方法(How to access a S4 object's method)[2022-09-15]
S4方法不起作用。 而是更新并返回对象 setMethod("deposit", signature = "Account", definition = function(.Object, amount) { .Object@balance <- .Object@balance + amount .Object }) acc = deposit(acc, 20) 不同的表述是写一个deposit<-替代方法 setGeneric("deposit<-", func ... -
您的代码中存在多个语法问题。 这段代码适合我。 library("parallel") accCost_wrap <- function(x){accCost2(h16,x)} #Instead of including h16 in the parRapply function, #just get it in the node environment cl = makeCluster(3) clusterExport(cl, c("h16", "accCost2")) #B wi ...
-
我假设这并不直接适用于您,但如果您正在为Bioconductor开发套件,那么有兴趣使用S4,因为他们积极鼓励使用它,并在十年之后的更好的部分 - 所有的核心包装大量使用S4。 我发现所有额外的开销是一个痛苦 - setGeneric,setMethod,处理NAMESPACE等。据说,我发现它强加的结构,可扩展性和其他这样的东西是值得的。 与所有事情一样,有折衷。 我认为它可以是一个很清洁 - 我不喜欢S3方法简单地通过命名约定伪装(foo.class)。 所有这一切,我倾向于避免在我自己的代码中使用S4 ...
-
方法被定义在泛型上,并在类上派发,而不是在类上派发。 所以this总是被派发的对象。 .A = setClass("A", slots = c(a = "integer")) setGeneric("foo", function(x) standardGeneric("foo")) setMethod("foo", "A", function(x) { x@a # 'x' is the object that `foo()` dispatches on, i.e., 'this' } ...
-
如何在Rcpp代码中从R包创建S4类的实例(How to create instances of S4 classes from R packages in Rcpp code)[2022-11-01]
您遇到的问题是尚未加载Matrix包。 因此,当Rcpp搜索dgCMatrix ctor时,它会变空,从而触发您看到的错误。 要解决这个问题,您只需在每个会话开始时加载一次Matrix库。 例如 library("Matrix") sourceCpp("path/to/S4_declaration.cpp") 或者,您可以在正在执行的sourceCpp编译中添加加载调用。 这有点极端,因为您只需要加载一次库。 但是,以下应始终在sourceCpp()下工作 #include// [[ ... -
请记住[只是另一个功能,因为[<- 。 所以为了做到 objPeople$FirstName[2] = "Joe" $将首先运行并返回[<-可以操作的东西。 就像是 '$<-'(objPeople, "FirstName", '[<-'( '$'(objPeople, "FirstName"), 2, "Joe")) 所以为了子集,它必须提取名字。 但随着 objPeople$FirstName = "Ambroze" 那只是一个 '$<-'( objPeople, "FirstName", "Am ...
-
您无法链接两个独立的对象,因此您需要使用两者的方法。 以下是替换方法的示例: Customer <- setClass( "Customer", slots=c( CustomerID="numeric", Name="character", OrderHistory="list" ), prototype=list(OrderHistory = list()) ) Order <- setClass( Class="Order", slot =c( ...
-
R中的S4对象创建(S4 object creation in R)[2022-05-27]
我要做的是,对于您在modelObject类中想要的每个插槽,确定期望值的范围。 例如, model槽必须支持模型训练函数可以返回的所有可能的对象类(例如lm(),glm(),nnet()等)。 在示例中,您会看到返回以下对象: ``` x <- y <- 1:10 class(lm(x~y)) class(glm(x~y)) class(nnet(x~y, size=10)) ``` 由于返回的对象之间没有公共类,因此使用S3语言可能更有意义,S3语法不太严格,并允许您将各种类型的输出分配给相同的字段名 ...