允许Web套接字的content-security-policy元标记(content-security-policy meta tag for allowing web socket)
情况:由content-security-policy元标记阻止的
phonegap serve
的自动phonegap serve
添加内容安全策略可防止自动重新加载
phonegap serve
实用程序。 这是建立在cordova serve
之上,但在文件编辑时自动重新加载应用程序。 它的工作原理是在index.html
注入socket.io
。 我应该在我的CSP元标记中指定哪些内容允许套接字连接到我的笔记本电脑。这是我目前的CSP元标记:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 192.168.0.100 * ws:* ; connect-src ws://192.168.0.100 ws:*">
但是在打开时,设备会一直显示“正在连接到设备”,而不会在设备上收到事件。
另请注意,它开始处理删除此元标记,这意味着
cordova-plugin-whitelist
可能无法阻止它。Situation: autoreload of
phonegap serve
blocked by content-security-policy meta tagAdding content security policy prevents auto-reload of
phonegap serve
utility. This is built on top ofcordova serve
but auto-reloads the app on file editing. It works by injectingsocket.io
inindex.html
. What should I specify in my CSP meta tag that will allow socket connections to my laptop.Here is my current CSP meta tag:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 192.168.0.100 * ws:* ; connect-src ws://192.168.0.100 ws:*">
However on opening, the device keeps showing "Connecting to device" and not event is received on the device.
Also note that it starts working on removing this meta tag which mean the
cordova-plugin-whitelist
might not be blocking it.
原文:https://stackoverflow.com/questions/32986074
最满意答案
事实证明,这些设备使用标准的Silicon Labs CP2102接口芯片,设备制造商加载了自定义
idProduct
编号。 虽然芯片与cp210x.ko
驱动程序100%兼容,但系统无法识别idProduct
,也不会将驱动程序与其关联。此时,有几种可能的解决方案:
- 手动指示系统将
cp210x.ko
驱动程序与此idProduct
一起使用。- 将
idProduct
添加到开源驱动程序 ,编译并安装它。 然后尝试将更改推送到标准Linux存储库。- 用通用芯片替换定制芯片。
- 重写芯片上的
idProduct
。我选择重写
idProduct
。 Silicon Labs有一个免费的实用程序可以做到这一点。 我设置了idProduct=EA60
,这是该芯片的默认设置。 该设备现在可以通过标准内置驱动程序识别,并且工作正常。It turns out this devices uses a standard Silicon Labs CP2102 interface chip, which the device manufacturer loaded with a custom
idProduct
number. While the chip is 100% compatible with thecp210x.ko
driver, theidProduct
is not recognized by the system, and does not associate the driver with it.At this point, there are several possible solutions:
- Manually direct the system to use the
cp210x.ko
driver with thisidProduct
.- Add the
idProduct
to the open source driver, compile, and install it. Then try to push the changes into standard Linux repositories.- Replace the customized chip with generic one.
- Rewrite the
idProduct
on the chip.I chose to rewrite the
idProduct
. Silicon Labs has a free utility to do just this. I set theidProduct=EA60
, which is the default for this chip. The device is now recognized by the standard built-in driver, and works perfectly.
相关问答
更多-
t420 integrated camera linux 摄像头在什么地方下载呀[2022-07-31]
您好,由于目前消费电脑大部分的驱动以及应用程序都是在windows 操作系统下开发的,还没有针对linux 系统的驱动程序,为了您电脑的正常运行,我们建议您使用windows 系统;如果您由于工作或学习需要,安装使用linux 系统,您可以到相关的专业论坛、网站上搜索相应设备的驱动程序。 -
适用于Linux的虚拟串行端口(Virtual Serial Port for Linux)[2023-01-31]
您可以使用pty(“伪电传”,其中串口是“真实电传”)。 从一端打开/dev/ptyp5 ,然后将程序附加到/dev/ttyp5 ; ttyp5将像串行端口一样执行,但将通过/ dev / ptyp5发送/接收它所做的一切。 如果真的需要它与一个名为/dev/ttys2的文件进行/dev/ttys2 ,那么只需将旧的/dev/ttys2从ptyp5转到ttys2 。 当然你可以使用ptyp5以外的其他ptyp5 。 也许选择一个高数字以避免重复,因为所有的登录终端也将使用ptys。 维基百科有更多关于pty ... -
事实证明,这些设备使用标准的Silicon Labs CP2102接口芯片,设备制造商加载了自定义idProduct编号。 虽然芯片与cp210x.ko驱动程序100%兼容,但系统无法识别idProduct ,也不会将驱动程序与其关联。 此时,有几种可能的解决方案: 手动指示系统将cp210x.ko驱动程序与此idProduct一起使用。 将idProduct添加到开源驱动程序 ,编译并安装它。 然后尝试将更改推送到标准Linux存储库。 用通用芯片替换定制芯片。 重写芯片上的idProduct 。 我选择 ...
-
在我的头顶,它是 stty -F /dev/ttySX raw -echo -echoe -echok -echoke 从手册页中可能会有更多标志: [-]crterase echo erase characters as backspace-space-backspace * crtkill kill all line by obeying the echoprt and echoe settings * -crtkill ...
-
Linux串口优先级(Linux serial port priority)[2022-05-08]
尝试使用setserial设置low_latency选项。 默认情况下,串行端口针对吞吐量而非延迟进行了优化,我认为此选项可让您更改它。 Try the using setserial to set the low_latency option. By default serial ports are optimised for throughput not latency, this option I think lets you change it. -
你是如何获得第一个串口的文件描述符的? 假设它是这样的: fd = open("/dev/serialPort0", O_RDWR); 你应该能够做到: fd2 = open("/dev/serialPort1", O_RDWR); 并获取用于其他串行端口的文件描述符。 写下你想要的每一个: char str1[] = "Hello, port 1!\n"; char str2[] = "hello, port 2!\n"; write(fd, str1, sizeof str1); write(fd ...
-
我的问题是我不知道应该如何理解我应该监视哪个串口。 如果这个“一个开发板”被Linux PC识别为USB小工具,则会有syslog条目。 断开电路板,等待15秒,然后连接电路板。 使用命令dmesg | tail dmesg | tail来检查syslog的结尾。 你可能得到这样的东西: $ dmesg | tail [ 2094.481014] usb 1-1: Product: EDBG CMSIS-DAP [ 2094.481019] usb 1-1: Manufacturer: Atmel Corp ...
-
没什么区别。 一些系统可能会为某些应用程序使用termcap 库 (offhand,可能只有Slackware),但是应用程序使用相同的库,无论它是否在串行端口上运行。 有几个应用程序使用termcap 接口来访问ncurses库(它提供了termcap和terminfo接口),但这并没有改变答案。 他们仍然会使用相同的库(和相同的接口),因为在同一个库的不同低级接口之间切换几乎没有意义。 “接口”当然是指用于初始化和查询终端数据库的少数功能。 使用termcap 接口到ncurses的应用程序仍然会获得t ...
-
不幸的是,现代伪终端并不那么容易。 在使用posix_openpt()或open("/dev/ptmx")主posix_openpt()之后,必须在主服务器及其相应的从服务器可用之前调用grantpt()和unlockpt() 。 ( openpty()等实用程序函数简化了这一点。) 作为一种解决方法,可以使用方便的社交场所 。 # terminal 1 socat pty:link=$PWD/pts unix-l:$PWD/ptm-pipe & dynamips -U $PWD/pts # termin ...
-
您可以使用QSerialPort port("/dev/ttyUSB0")构造串行端口对象。 此QSerialPort构造函数接受它在QSerialPortInfo::portName()存在的形式的端口名称。 没有记录这个名称是"/dev/ttyUSB0"形式,但似乎是这样。 You can construct a serial port object using QSerialPort port("/dev/ttyUSB0"). This QSerialPort constructor accepts ...