RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-336756

gfd2's questions

Martin Hope
gfd2
Asked: 2023-06-16 14:26:21 +0000 UTC

从 ELM327 读取数据时出现问题

  • 6

也许这个问题在这里会跑题,但是我不知道如何处理出现的问题。我不想半途而废。

这个想法是在arduino上创建一个蓝牙设备,使用蓝牙模块HC-05从机器(ELM327 v2.1)读取数据。

在此代码中,蓝牙模块切换到主模式并使用其 MAC 地址连接到 ELM327。模块在评论中的代码中回答。

#include <SoftwareSerial.h>
SoftwareSerial bluetoothSerial(4, 5);

void setup() {
  Serial.begin(9600);
  Serial.print("Готов)");
  bluetoothSerial.begin(38400);
  delay(1000);
  getSetAtCommand("AT");                         //OK
  getSetAtCommand("AT+CMODE=0");                 //OK
  getSetAtCommand("AT+PSWD=1234");               //OK
  getSetAtCommand("AT+ROLE=1");                  //OK
  getSetAtCommand("AT+BIND=0010,CC,4F3603");     //OK
  getSetAtCommand("AT+LINK=0010,CC,4F3603");     //OK
  delay(1000);
  getSetAtCommand("AT+STATE?");  // OK: CONNECTED
}

char buffer[50];
int i = 0;

void loop() {
  while (Serial.available() > 0) {
    char c = Serial.read();
    if (c != '\n' && i < 49) {
      buffer[i++] = c;
    } else {
      buffer[i] = '\0';
      //Serial.println(buffer);
      getSetAtCommand(buffer);
      i = 0;
    }
  }
}

void getSetAtCommand(String command) {
  Serial.println(command);
  String added_command = command + "\r\n";
  bluetoothSerial.print(added_command);
  delay(500);
  while (bluetoothSerial.available()) {
    Serial.write(bluetoothSerial.read());
  }
}

由于 State 返回 CONNECTED,我假设它已连接到 ELM。

模块不响​​应命令AT+PAIR=0010,CC,4F3603,20\r\n。模块等命令ATZ\r\n, AT015B\r\n, 015B\r\n, ATRV\r\n, 0105\r\n, at i\r\n, at rv\r\n, ati\r\n, atrv\r\n也没有响应。有时 ERROR [0] 回答,据我了解这意味着没有这样的命令。

在我看来,这些命令根本达不到 ELM。可能是什么问题呢?

ELM327 本身可以工作,它可以毫无问题地连接到手机并显示数据。

我通过笔记本电脑上的模拟器进行了尝试,连接的蓝牙模型显示在笔记本电脑的蓝牙设备中,也无法像 ELM 那样工作。代码的第一个版本:

#include <SoftwareSerial.h>
SoftwareSerial bluetoothSerial(4, 5);

void setup() {
  Serial.begin(9600);
  Serial.print("Готов)");
  bluetoothSerial.begin(38400);
  delay(1000);
  getSetAtCommand("AT");                         //OK
  getSetAtCommand("AT+CMODE=0");                 //OK
  getSetAtCommand("AT+PSWD=1234");               //OK
  getSetAtCommand("AT+ROLE=1");                  //OK
  getSetAtCommand("AT+BIND=0010,CC,4F3603");     //OK
  getSetAtCommand("AT+LINK=0010,CC,4F3603");     //OK
  delay(1000);
  getSetAtCommand("AT+STATE?");  // OK: CONNECTED
  delay(1000);
  getSetAtCommand("ATZ");      //нет ответа                 
  getSetAtCommand("AT015B");//нет ответа
  getSetAtCommand("015B");             //нет ответа           
  getSetAtCommand("ATRV");//нет ответа
  getSetAtCommand("0105");    //нет ответа                   
  getSetAtCommand("at i");//нет ответа
  getSetAtCommand("at rv");   //нет ответа                    
  getSetAtCommand("ati");//нет ответа
  getSetAtCommand("atrv");//нет ответа
}

void loop() {
}

void getSetAtCommand(String command) {
  Serial.println(command);
  String added_command = command + "\r\n";
  bluetoothSerial.print(added_command);
  delay(500);
  while (bluetoothSerial.available()) {
    Serial.write(bluetoothSerial.read());
  }
}
Serial.print("atsp5 )");
bluetoothSerial.print("atsp5\r\n");
delay(1000);
while (bluetoothSerial.available()) {
  Serial.write(bluetoothSerial.read());
}
c++
  • 1 个回答
  • 48 Views
Martin Hope
gfd2
Asked: 2022-06-05 17:40:58 +0000 UTC

使用 ViewBag 选择标签集值

  • 0

有一个选择元素,其中有 3 个选项。页面使用ViewBag接收true或false。如果为true,则将select设置为“Yes”,如果为false,则将其设置为“No”。在互联网上找不到任何东西。请帮帮我 :)

<select id="selectId">
    <option>Не выбрано</option>
    <option value="true">Да</option>
    <option value="false">Нет</option>
</select>
c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2022-04-15 18:09:12 +0000 UTC

使用 Apache 特定的 salted MD5 算法生成密码哈希

  • 3

您需要从 C# 中的登录名和密码中获取此字符串。

test:$apr1$zg40inu2$fb4NUdl7Gj4yfKIwWJFt//

此行包含用户名和密码test。想不通。

c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2022-01-02 05:32:12 +0000 UTC

使用htmlagilitypack解析时如何从属性“a”中获取文本与“strong”中的内容进行比较

  • 1

对不起标题,我不知道怎么写。有一个包含几个li 的div块。每个li包含书的年份、作者、版权所有者等。我只想获取版权所有者。我想要做到这一点,我需要找到它在li中所说的位置,并使用(Atticus ABC)获取文本。我尝试了许多不同的方法,但都没有奏效。<strong> Правообладатель:</strong>

<div class="blocks">
<li>...</li>
<li>...</li>
<li>
<strong>Правообладатель:</strong>
<a href="/azbuka-attikus/">Азбука-Аттикус</a>
</li>
<li>...</li>
</div>

我试过这样:

HtmlNode pravo = document.DocumentNode.SelectSingleNode("//li/strong[@text='Правообладатель:']/a");

我知道这样我将无法从a获取文本,但我不再有任何想法如何做到这一点。

c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2022-01-02 02:16:27 +0000 UTC

使用htmlagilitypack c#解析网站时的额外文本

  • 1

从这里我想只取文本“空中城堡”,但在尝试解析时,它总是完全取走它,结果是“空中文本城堡”。如果用 div 和 h1 解析,还是一样的。也许您可以以某种方式例外,以便它跳过跨度。我只是不想剪掉它,因为在不同的书中,它是不同的。例如:PDF、音频、文本。我找不到。下面我将举例说明我是如何尝试这样做的,但它没有正常工作。

<div class="biblio_book_name biblio-book__title-block">
<h1 itemprop="name">Воздушный замок
<span class="label label-text">Текст</span>
</h1>
</div>

1路

HtmlNode name = document.DocumentNode.SelectSingleNode("//h1[@itemprop='name']");

2种方法

HtmlNode name = document.DocumentNode.SelectSingleNode("//div[@class='biblio_book_name biblio-book__title-block']");
c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2021-11-06 21:40:25 +0000 UTC

Quartz.NET 不适用于实体框架

  • 1

如果我在OrderTime类中创建具有基的构造函数,则Execute方法将停止工作。谁知道如何解决这个问题?有可能以其他方式实现它。我在互联网上找不到解决方案。请帮帮我。班级OrderTime

public class OrderTime : IJob
    {
        AppDBContent appDBContent;
        public OrderTime(AppDBContent appDBContent)
        {
            this.appDBContent = appDBContent;
        }
        public async Task Execute(IJobExecutionContext context)
        {
            var order = appDBContent.Order.FirstOrDefault(e => e.Id == 52);
            if (order != null)
            {
                order.Mail = "admin";
            }
            appDBContent.Order.Update(order);
            appDBContent.SaveChanges();
        }
    }

数据库类AppDBContent

public class AppDBContent : IdentityDbContext<User>
    {

        public AppDBContent(DbContextOptions<AppDBContent> options) : base(options)
        {
            //Database.EnsureCreated();
        }

        public override DbSet<User> Users { get; set; }
        public DbSet<Book> Book { get; set; }
        public DbSet<Сategories> Categories { get; set; }
        public DbSet<BookItems> LibraryBookItem { get; set; }
        public DbSet<Order> Order { get; set; }
        public DbSet<OrderDetail> OrderDetail { get; set; }

    }
c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2020-04-12 17:04:04 +0000 UTC

凯撒密码和维热内密码。无法在文本框中显示响应

  • 0

我想使用接口和类来实现Caesar和Vigenère加密方法。代码有效。它从textBox1.Text、textBox3.Text的值中读取并加密,但是不知道点击按钮时如何输出对textBox2.Text的响应。Vigenère 课程没有开始。请帮我整理一下)代码:

namespace Цезарь_и_Виженера
{
    interface IEncrypt
    {
        void Encrypt(string text, string key); //зашифровать
        void Decrypt(string text, string key); //расшифровать
        string Text { get; set; } //текст
    }
    class Cipher
    {
        public IEncrypt Encrypter { get; set; }
        public void Encrypt(string text, string key)
        {
            Encrypter.Encrypt(text, key);
        }
        public void Decrypt(string text, string key)
        {
            Encrypter.Decrypt(text, key);
        }
    }
    class Caesar : IEncrypt
    {
        const string alfabet = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
        public string Text { get; set; }
        private void CodeEncode(string text, int key)
        {
            //добавляем в алфавит маленькие буквы
            var fullAlfabet = alfabet + alfabet.ToLower();
            var letterQty = fullAlfabet.Length;
            var retVal = "";
            for (int i = 0; i < text.Length; i++)
            {
                var c = text[i];
                var index = fullAlfabet.IndexOf(c);
                if (index < 0)
                {
                    //если символ не найден, то добавляем его в неизменном виде
                    retVal += c.ToString();
                }
                else
                {
                    var codeIndex = (letterQty + index + key) % letterQty;
                    retVal += fullAlfabet[codeIndex];
                }
            }
            Text = retVal;
        }
        public void Encrypt(string text, string key)
        {
            CodeEncode(text, Convert.ToInt32(key));

        }
        public void Decrypt(string text, string key)
        {
            CodeEncode(text, -Convert.ToInt32(key));
        }
    }
}
public partial class Form1 : Form
{
    Cipher cipher = new Cipher();
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
            cipher.Encrypter = new Caesar();
            cipher.Encrypt(textBox1.Text, textBox3.Text);
            textBox2.Text =         
    }
}
c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2020-01-27 16:56:28 +0000 UTC

如何在没有延迟()的情况下闪烁 LED?

  • 1

有 4 个 LED。我需要 1 个 LED 燃烧 8 秒,另外 3 个 LED 燃烧 500 毫秒。怎么做?编码:

byte r1 = 2;
byte y1 = 3;
byte b1 = 4;
byte r2 = 5;
void setup() {
  pinMode(r1, OUTPUT);
  pinMode(y1, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(r2, OUTPUT);
}
void Svet1()
{
  digitalWrite(r2, LOW);
  digitalWrite(r1, HIGH);
}
void Svet2()
{
  digitalWrite(r1, LOW);
  digitalWrite(y1, HIGH);
}
void Svet3()
{
  digitalWrite(y1, LOW);
  digitalWrite(b1, HIGH);
}
void Svet4()
{
  digitalWrite(b1, LOW);
  digitalWrite(r2, HIGH);
}
void loop() {

}
c++
  • 3 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2020-12-30 04:03:54 +0000 UTC

如何替换延迟()?

  • 0

有 4 个方法 Clock();Data();Temp();Hum();。一段代码必须在没有延迟()的情况下完成。如何实施?不工作。例如,首先触发 Clock(),然后触发 Hum(),再次触发 Clock(),然后触发 Temp() 和 Hum()。编码:

Clock();
delay(5000);
Data();
delay(2000);
Temp();
delay(2000);
Hum();
delay(2000); 
Моя 1 попытка:
void loop() {
  if (round(millis() / 5000) % 2 == 0) {
    Clock();
  }
  if (round(millis() / 2000) % 2 == 0) {
    Data();
  }
  if (round(millis() / 2000) % 2 == 0) {
    Temp();
  }
  if (round(millis() / 2000) % 2 == 0) {
    Hum();
  }
}
2 попытка:
if ( millis() - time1 > 5000)
  {
    Clock();
    time1 = millis();
  }
  if ( millis() - time2 > 2000)
  {
    Data();
    time2 = millis();
  }
  if ( millis() - time3 > 2000)
  {
    Temp();
    time3 = millis();
  }
  if ( millis() - time4 > 2000)
  {
    Hum();
    time4 = millis();
  }
3 попытка:
if ( millis() - time1 > 5000)
  {
    Clock();
    time1 = millis();
  }
  else
  {
    Data();
  }
  if ( millis() - time2 > 2000)
  {
    Temp();
    time2 = millis();
  }
  else
  {
    Hum();
  }
c++
  • 2 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2020-11-10 04:44:57 +0000 UTC

我无法解决错误当前上下文中不存在名称“”。C#语言。请帮帮我

  • 2

引发以下错误:当前上下文中不存在名称“Lampaas[i]”。Visual Studio 突出显示的错误用星号 (*) 突出显示,更准确地说,Lampaas[i] 和 Lamppass[b] 是写入错误的地方。C#语言。我按升序对对象进行排序,所有内容都按字段 public int capacitylamp { get; 放; }。

using System;
namespace Laba_6
{
    class Lampa : IComparable<Lampa>
    {
        public string typelamp { get; set; }
        public int capacitylamp { get; set; }
        public int c_outlamp { get; set; }

        public Lampa(string typelamp, int capacitylamp, int c_outlamp)
        {
            this.typelamp = typelamp;
            this.capacitylamp = capacitylamp;
            this.c_outlamp = c_outlamp;
        }

        public int CompareTo(Lampa p)
        {
            return this.capacitylamp.CompareTo(p.capacitylamp);
        }
        class Lamps
        {
            Lampa[] Lampas = new Lampa[7];
            public Lampa this[int pos]
            {
                get
                {
                    if (pos >= 0 || pos < 7) return Lampas[pos];
                    else throw new IndexOutOfRangeException("Вне диапазона!");
                }
                set { Lampas[pos] = value; }
            }
        }

        class Program
        {
            public void Print()
            {
                for (int b = 0; b < 7; b++)
                {
                    Console.WriteLine($"Тип лампы: **{Lampaas[b]**.typelamp}. Потребляемая мощность: {**Lampaas[b]**.capacitylamp} Вт. Выходная мощность {**Lampaas[b]**.c_outlamp} Вт.");
                    Console.WriteLine();
                }
            }
            public void Sort_select() // сортировка методом прямого выбора
            {

                for (int i = 0; i < 6; i++)
                {
                    int min = i;
                    for (int j = i + 1; j < 7; j++)
                    {
                        if (**Lampaas[i]**.CompareTo(**Lampaas[j]**) > 0)
                        {
                            min = j;
                        }
                    }
                    var temp = **Lampaas[i]**;
                    **Lampaas[i]** = **Lampaas[min]**;
                    **Lampaas[min]** = temp;

                }
            }

            public void Sortbubble()
            {
                for (int i = 0; i < 7; i++)
                {
                    for (int j = i + 1; j < 7; j++)
                    {
                        if (**Lampaas[i]**.CompareTo(**Lampaas[j]**) > 0)
                        {
                            var t = **Lampaas[i];**
                            **Lampaas[i]** = **Lampaas[j]**;
                            **Lampaas[j]** = t;
                        }
                    }
                }
            }
            static void Main(string[] args)
            {
                Lamps Lampaas = new Lamps();
                Lampaas[0] = new Lampa("Накаливание", 100, 100);
                Lampaas[1] = new Lampa("Светодиодная", 20, 100);
                Lampaas[2] = new Lampa("Люминесцентные", 50, 100);
                Lampaas[3] = new Lampa("Галогенная", 150, 150);
                Lampaas[4] = new Lampa("Газоразрядные", 110, 150);
                Lampaas[5] = new Lampa("Энергосберегающая", 15, 100);
                Lampaas[6] = new Lampa("Неоновая", 250, 350);
                Console.ForegroundColor = ConsoleColor.Green;
                Program sort = new Program();
                //sort.Print();
                //sort.Sort_select();
                sort.Sortbubble();
                sort.Print();
                Console.WriteLine();
                sort.Sort_select();   
                sort.Print();
                Console.ReadKey();
            }

        }

    }

}
c#
  • 1 个回答
  • 10 Views
Martin Hope
gfd2
Asked: 2020-11-07 03:12:02 +0000 UTC

如何相互比较对象,仍然是数组?

  • 1

我需要相互比较对象,它们仍然是数组。然后使用冒泡法对它们进行排序。我需要按容量灯排序。请帮帮我。我知道我的排序根本不正确,我需要使用 CompareTo。对于不好的代码,请不要严格判断。编码:

using System; 
namespace Laba_6 {
    class Lampa : IComparable<Lampa>
    {
        public string typelamp;
        public int capacitylamp;
        public int c_outlamp;

        public Lampa(string typelamp, int capacitylamp, int c_outlamp)
        {
            this.typelamp = typelamp; 
            this.capacitylamp = capacitylamp;
            this.c_outlamp = c_outlamp;
        }
        public int CompareTo(Lampa p)
        {
            return this.capacitylamp.CompareTo(p.capacitylamp);
        }
        class Lamps //класс для хранения множества элементов, класс контейнер
        {
            Lampa[] Lampas = new Lampa[4]; //массив содежащий 7 элементов
            public Lampa this[int pos]
            {
                get //проверка количества элементов массива
                {
                    if (pos >= 0 || pos < 4) return Lampas[pos];
                    else throw new IndexOutOfRangeException("Вне диапазона!");
                }
                set { Lampas[pos] = value; }
            }
        }
        class Program
        {
            public void Sortbubble()
            {
                for (int i = 0; i < 4; i++)
                {
                    for (int j = i + 1; j < 4; j++)
                    {
                        if (Lampaas[i] > Lampaas[j])
                        {
                            int t = Lampaas[i];
                            Lampaas[i] = massiv[j];
                            massiv[j] = t;
                        }
                    }
                }
            }
            static void Main(string[] args)
            {
                Lamps Lampaas = new Lamps();
                Lampaas[0] = new Lampa("Накаливание", 100, 100);
                Lampaas[1] = new Lampa("Светодиодная", 20, 100);
                Lampaas[2] = new Lampa("Люминесцентные", 50, 100);
                Lampaas[3] = new Lampa("Галогенная", 150, 150);
                Lampa[] massiv = new Lampa[] { Lampaas[0], Lampaas[1], Lampaas[2], Lampaas[3], Lampaas[4], Lampaas[5], Lampaas[6], Lampaas[7] };
                Console.ForegroundColor = ConsoleColor.Green;
                Program sort = new Program();
                Console.WriteLine();
                sort.Sortbubble();
                for (int b = 0; b < 4; b++)
                {
                    Console.WriteLine($"Тип лампы: {Lampaas[b].typelamp}. Потребляемая мощность: {Lampaas[b].capacitylamp} Вт. Выходная мощность {Lampaas[b].c_outlamp} Вт.");
                    Console.WriteLine();
                }
                Console.ReadKey();
            }

        }
    } 
}
c#
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5