LINUX.ORG.RU

Ответ на: комментарий от Slavik763

В общем что сделал:

  1. Изменил /boot/config.txt
enable_uart=1
dtoverlay=disable-bt
gpio=17=a3
dtoverlay=miniuart-ctsrts

2.Проверил GPIO

root@pi:~# raspi-gpio get 17
GPIO 17: level=1 fsel=7 alt=3 func=RTS0 pull=DOWN
  1. Изменил /boot/cmdline.txt добавил dwc_otg.lpm_enable=0 console=tty1 и получил общее: wc_otg.lpm_enable=0 console=tty1 root=PARTUUID=f2412780-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles 4.Далее выполнил скрипт:
  2. git clone https://github.com/mholling/rpirtscts.git
  3. cd rpirtscts
  4. make получил make: «rpirtscts» не требует обновления.
  5. ./rpirtscts on
  6. chown root rpirtscts
  7. chmod 4755 rpirtscts
  8. stty -F /dev/ttyAMA0 crtscts далее вышел
  9. Далее запустил:
#include "mainwindow.h"
#include <QApplication>
#include <cstring>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <linux/serial.h>
#include <sys/ioctl.h>
#include <QDebug>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

    struct serial_rs485 rs485conf;
    memset(&rs485conf, 0, sizeof(rs485conf));
    int fd = open ("/dev/ttyAMA0", O_RDWR);
    if (fd < 0) {
            qDebug()<<"Error: Can't open: /dev/ttyAPP1";
    }

    if (ioctl (fd, TIOCGRS485, &rs485conf) < 0) {
               qDebug()<<"Error: TIOCGRS485 ioctl not supported";
    }

    rs485conf.flags |= SER_RS485_ENABLED;
    rs485conf.flags |= SER_RS485_RTS_ON_SEND;
    rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);
    rs485conf.delay_rts_before_send = 100;
    rs485conf.delay_rts_after_send = 100;


    if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) {
           // qDebug()<<"Error: TIOCSRS485 ioctl not supported.";
       qDebug()<< errno << strerror( errno );
    }

    for(;;) {
        int n = write(fd, "ABC\r\n", 5);
        if (n < 0) {
        /* Error handling */
            break;
        }
        usleep(50000);
    }
}

Не увидал изменений на GPIO17. Сигнал передачи есть. Проверял осцилографом. Строчка ioctl (fd, TIOCSRS485, &rs485conf) вернула ошибку 25 Неприменимый к данному устройству ioctl

Alex_Golubev
() автор топика
Последнее исправление: Alex_Golubev (всего исправлений: 2)