Ich verwende den folgenden Code, um mit dem Gerät zu interagieren: < /p>
using System;
using System.IO.Ports;
using System.Windows.Forms;
namespace DEVICE_INFO
{
public partial class Form1 : Form
{
SerialPort serialPort;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string portName = "COM6"; // Specify your COM port (change if needed)
int baudRate = 115200; // Try different baud rates (9600, 38400, 115200)
serialPort = new SerialPort(portName, baudRate)
{
ReadTimeout = 5000, // Timeout for reading data (5 seconds)
WriteTimeout = 3000, // Timeout for writing data (3 seconds)
DtrEnable = true, // Some devices require this setting
RtsEnable = true, // Some devices require this setting
Encoding = System.Text.Encoding.ASCII
};
serialPort.DataReceived += SerialPort_DataReceived;
serialPort.Open(); // Open the serial port
// Send AT commands to request SIM card and device information
serialPort.WriteLine("AT\r\n");
MessageBox.Show("Reading data from device...", "Device Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message, "Device Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// Event handler for receiving data
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
string rawData = serialPort.ReadExisting(); // Read incoming data
// Display the response in the RichTextBox in the UI thread
this.Invoke((MethodInvoker)delegate
{
richTextBox1.AppendText(rawData + "\n"); // Append response to the RichTextBox
});
}
catch (Exception ex)
{
MessageBox.Show("Read Error: " + ex.Message, "Device Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
< /code>
Ich erhalte Fehler < /p>
[L610_cldsd_load.c] -DR_RecvData_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_load.c] -DR_RecvData
_Analysis- Line=1292:, the
iRet=-5006
[L610_cldsd_uart.c]
-DR_Uart0_Handle- Line=88:DR_Rec
vData_Analysis iRet=-5006
< /code>
Diese Fehlermeldung scheint von der Gerätefirmware zu stammen. Ich habe verschiedene Ansätze zum Senden von Befehlen ausprobiert, aber das Gerät antwortet nicht wie erwartet.
- Überprüfen der COM -Portverbindung. LI> Senden von verschiedenen Befehlen wie "AT+GMR" für die Firmware -Version und "AT+CGSN" für IMEI. /li>
< /ol>
Frage -< /strong> < /p>
Wie kann ich richtig abrufen Die IMEI, die Seriennummer und andere Gerätedetails eines Geräts, das über USB COM -Port in C#? ?
Ich würde mich über Hilfe oder Vorschläge freuen. Danke!