- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上,我想将我的计算机放在串行线路的中间并记录通过它的对话。我正在尝试对这段对话进行逆向工程,并最终模拟对话的一端。
我正在尝试做的粗略图表:
通常,我有这个:
__________ __________
| | | |
|Device 1|<======>|Device 2|
|________| |________|
__________ __________ __________
| | | | | |
|Device 1|<===>|Computer|<===>|Device 2|
|________| |________| |________|
最佳答案
好吧,一种以编程方式执行此操作的方法是打开相关设备,并开始在它们之间转发数据,同时保存到文件中。
大多数任何语言都可以做到。有一些很好的库,用于诸如 java 和 python 之类的东西。
网络上存在几种实现,我通过谷歌搜索找到了一个名为 Telnet Serial Bridge (TSB) 的 python,它允许您通过以太网将连接桥接在一起,并使用诸如 putty 之类的 telnet 工具进行日志记录。
虽然在过去,我使用了来自 rxtx.qbang.org 的 java rxtx 串行通信库。自己做,虽然我怀疑现在有一个更新的版本,或者可能是 JVM 内置的东西。
改编自该网站上的示例:
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TwoWaySerialComm
{
void bridge( String portName1, String portName2 ) throws Exception
{
CommPortIdentifier portIdentifier1 = CommPortIdentifier.getPortIdentifier(portName1);
CommPortIdentifier portIdentifier2 = CommPortIdentifier.getPortIdentifier(portName2);
if ( portIdentifier1.isCurrentlyOwned() || portIdentifier2.isCurrentlyOwned())
{
System.out.println("Error: Port is currently in use");
}
else
{
CommPort commPort1 = portIdentifier1.open(this.getClass().getName(),2000);
CommPort commPort2 = portIdentifier2.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort && commPort2 instanceof SerialPort )
{
SerialPort serialPort1 = (SerialPort) commPort1;
serialPort1.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in1 = serialPort1.getInputStream();
OutputStream out1 = serialPort1.getOutputStream();
SerialPort serialPort2 = (SerialPort) commPort2;
serialPort2.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in2 = serialPort2.getInputStream();
OutputStream out2 = serialPort2.getOutputStream();
(new Thread(new SerialReader(in1, out2))).start();
(new Thread(new SerialReader(in2, out1))).start();
}
else
{
System.out.println("Error: Only serial ports are handled by this example.");
}
}
}
/** */
public static class SerialReaderWriter implements Runnable
{
InputStream in;
OutputStream out;
public SerialReader ( InputStream in, OutputStream out )
{
this.in = in;
this.out = out;
}
public void run ()
{
byte[] buffer = new byte[1024];
int len = -1;
try
{
while ( ( len = this.in.read(buffer)) > -1 )
{
out.write(buffer,0, len);
System.out.print(new String(buffer,0,len));
}
}
catch ( IOException e )
{
e.printStackTrace();
}
}
}
public static void main ( String[] args )
{
try
{
(new TwoWaySerialComm()).bridge("COM1", "COM3");
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
关于serial-port - 如何在软件中将两个物理串行端口相互桥接(并记录通过的数据)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4029255/
我有一个在 Silverlight 中开发的应用程序,它必须连接到另一个我无法控制的遗留应用程序,它需要 3005 端口上的 TCP 连接。 我无法修改旧版应用程序以将端口置于 silverlight
我主要使用 Git 工作,并且在 github 上有很多代码。我也想把它放在 Bitbucket 上,供使用 mercurial 的人使用,但更重要的是,因为我也想在我的 domian 上拥有代码,而
有一个emacs插件可以在emacs中直接编辑confluence页面: http://code.google.com/p/confluence-el/ VIM 有类似的东西吗?我无法找到一些东西。
我已在项目中添加了桥接 header ,但随后我也收到“ProjectName\ProjectName - Bridging-Header.h”文件不存在的错误。 最佳答案 在build设置中,为桥接
我有带 libvirt/kvm 虚拟化的 Linux 主机,虚拟机需要“真实的”静态 IP 地址,所以我决定设置桥接网络。我在主机和虚拟机属性中创建了 br0,我设置了源设备:主机设备 vnet0(B
我正在尝试实现以下模型:我有一个包含一些记录(就像可编辑枚举)的字典表(ProductOffer 表)。另外,我有一个主表 (ChangeNet),它应该存储 ProductOffer 的集合。字典不
我有一个理论,但我不知道如何验证它。我们有一个相当大的 iOS 项目,包含大约 200 个 Swift 文件和 240 个 obj-C 文件(以及等量的头文件)。我们仍在使用 Swift 1.2,这意
简而言之,我正在开发一个嵌入式系统,除其他外,它需要一个从 USB 主机端口到设备端口的桥(这只是第一步,稍后传输的信息将被过滤和更改) . 考虑到这基本上是一个 USB 窥探器/嗅探器,我认为应该有
欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码): https://github.com/zq2599/blog_demos 关于《Strimzi K
网上搜出来的比较乱,讲的不明不白,因此根据自己弄过一次,确认可行的方式,做个备份,方便日后查阅。 环境: 在oracle vm virtualbox中安装的ubuntu,具体版本名是:ubunt
Symfony 的 bundle、vendor 和 bridge 是什么意思? 最佳答案 小贩 一般来说,vendor是项目的依赖项(又名第三方库)。在 Symfony2 中也是同样的意思。 捆 来自
我正在尝试发布发送到 NSB 主机的 WCF 服务。我查看了 NSB 示例中的 WebServiceBridge 示例,但无法弄清楚如何在 WCF 对应项中使用 NServiceBus.WcfServ
我目前正在尝试将 Google Cloud Messaging 库实现到我的 IOS 应用程序中。我按照说明 from here. 进行操作 但是我遇到了桥接头问题。 This is how my p
我正在快速构建一个 Firebase 应用程序,我正确安装了 cocoa pod,然后创建了一个 Objective-C 文件,这样它就可以使我成为一个桥接 header 。当我尝试在应用程序的其他地
我添加到我的项目桥接头文件中,这样我就可以在 swift 中使用 opencv。我决定我不需要 opencv 所以我删除了桥接头文件,在我这样做之后我无法运行我的项目因为这个错误: :0: 错误:打开
我正在使用 Xcode 8.0,我已经手动创建了 Swift Bridging Header。但是我在 Swift Compiler – Code Generation 下找不到选项 Ojective
我有一个 iphone 应用程序,可以通过以 packages 的形式下载额外的内容来丰富它。 此附加内容(包)是使用 MAC OS 应用程序构建的。 MAC OS 应用程序用于收集资源和艺术品、进行
virtualbox中有四种网络连接方式: nat bridged adapter internal host-only adapter vmware中有三种,其实它跟
网上搜出来的比较乱,讲的不明不白,因此根据自己弄过一次,确认可行的方式,做个备份,方便日后查阅。 环境: 在oracle vm virtualbox中安装的ubuntu,具体版本名是:ubuntu
我正在使用 PHP/Java 桥接您可以找到的获取资本 API here .但是在使用 PHP/Java bridge 连接后(它连接正确并且我测试过),我正在尝试通过为此创建一个对象来使用 API,
我是一名优秀的程序员,十分优秀!