我目前正在尝试通过BluetoothChat示例应用程序与ELM327 OBDII蓝牙加密狗进行通信.我能够连接,因为我已经更改了UUID,但是我只能接收启动命令和提示">"发送命令,每当我尝试发送命令时,我得到以下内容
现在我在这里读到将"\ r"附加到命令,但是当我这样做时,我得到完全相同的响应.我正在使用示例应用程序"BluetoothChat"
主类......
public class BluetoothChat extends Activity {
// Debugging
private static final String TAG = "BluetoothChat";
private static final boolean D = true;
// Message types sent from the BluetoothChatService Handler
public static final int MESSAGE_STATE_CHANGE = 1;
public static final int MESSAGE_READ = 2;
public static final int MESSAGE_WRITE = 3;
public static final int MESSAGE_DEVICE_NAME = 4;
public static final int MESSAGE_TOAST = 5; …Run Code Online (Sandbox Code Playgroud) 我正在尝试打开我计划转换为十六进制的二进制文件但是我遇到了通过FileStream读取文件的问题,
private void button1_Click(object sender, EventArgs e)
{
openFD.Title = "Insert a BIN file";
openFD.InitialDirectory = "C:"; // Chooses the default location to open the file
openFD.FileName = " "; // Iniitalizes the File name
openFD.Filter = "Binary File|*.bin|Text File|*.txt"; // FIlters the types of files allowed to by chosen
if (openFD.ShowDialog() != DialogResult.Cancel)
{
chosenFile = openFD.FileName;
string directoryPath = Path.GetDirectoryName(chosenFile); // Returns the directory and the file name to reference the file
string dirName = System.IO.Path.GetDirectoryName(openFD.FileName); // Returns …Run Code Online (Sandbox Code Playgroud) 我有一个以字符串格式表示的字节列表,例如,当我在Python3.3中打印列表时,我得到以下输出:
DATA = ['FF', 'FF', 'FF', 'FF']
Run Code Online (Sandbox Code Playgroud)
我想将这些转换为字节,例如0xFF,0xFF,0xFF,0xFF.我尝试过bytearray()函数,但这会返回错误.
我猜我在这里错过了一些简单的东西,但我已经环顾了SO和谷歌并且到目前为止没有运气
谢谢!
好的,所以我正在编写另一个程序来操作二进制文件.这个程序导入的文件大于我之前必须操作的文件,大约12K.
我很好奇Stream.read命令是如何工作的......我知道这听起来很简单,但我怎么知道文件已被完全读取以便我可以开始操作它,就像现在我一样这段代码......
// Opens a stream to the path chosen in the open file dialog
using (FileStream stream = new FileStream(chosenFile, FileMode.Open, FileAccess.Read))
{
size = (int)stream.Length; // Returns the length of the file
data = new byte[size]; // Initializes and array in which to store the file
stream.Read(data, 0, size); // Begins to read from the constructed stream
progressBar1.Maximum = size;
while (byteCounter < size)
{
int i = data[byteCounter];
byteCounter++;
progressBar1.Increment(1);
}
}
Run Code Online (Sandbox Code Playgroud)
我知道这非常简单,但是有人可以向我解释stream.Read是如何工作的,它是否将所有内容存储到字节数组"data"中然后我可以按照我认为合适的方式操作它,或者我是否必须操纵它正在阅读的文件.我再次道歉,如果这是基本的,所有的想法都表示赞赏
我认为我误解了获得的目的; 组; 在C#中.我有一个我正在尝试填充的双打列表,我正在使用以下代码...这两个都在同一个类中,当我尝试运行它时,我在尝试填充列表时得到一个Null引用异常.我到底误解了什么?
public List<double> NewData
{ get; set; }
public InfoFile(String fileName, String groupName)
{
this.group = groupName;
test = File.ReadAllLines(fileName);
FileInfo label = new FileInfo(fileName);
this.name = Path.GetFileName(fileName);
isDrawn = false;
for (int t = 2; t < test.Length; t++)
{
NewData.Add(double.Parse(test[t].Substring(6, 4)));
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 C 语言开发 GameBoy 模拟器。现在我正在处理 CPU.c 文件,但我对此处列出的一些说明感到有些困惑:
http://realboyemulator.files.wordpress.com/2013/01/gbcpuman.pdf
如果您参考上述 PDF 的第 66 页,并查看与操作码 0x7E -- LD,R1,R2 相对应的指令,我对这不是结构很好奇..
GB 有 8 个 8 位寄存器,A、B、C、D、E、F、H、L。16 位寄存器可以通过连接两个:AF、BC、DE、HL 来构成。
我对操作码 0x7E 感到困惑,因为它看起来像是试图将 16 位值 (HL) 存储到 8 位寄存器 (A) 中。
LD,A,(HL)
我误解了这份文件吗?有人可以解释为什么会存在这样的指令吗?难道不能只用LD,A,L代替吗?
我正在使用C#中的Regex,并且无法找到我正在寻找的这个示例.我有一个字符串,结构如下
string arg = "Type / Subtype: 001 / 002 Additional pointless information that we don't need"
Run Code Online (Sandbox Code Playgroud)
基本上我想知道的是如何在C#中格式化正则表达式以获得此字符串中的两个数字.最后的附加信息是动态的,因此我无法对该信息进行硬编码.
所以我现在就像这样:
Regex r = @Type / SubType: (\d+) / (\d+) ";
Run Code Online (Sandbox Code Playgroud)
但我不知道最后要放弃什么来忽略尾随的角色,任何想法?