[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4678: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4680: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4681: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4682: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
virt2real.ru • Просмотр темы - Не заводится UART1




 

Управляем чем угодно откуда угодно

Не заводится UART1

Виртурилка, 3G/4G, WiFi, моторчики, датчики, GPS и прочее - питание, драйвера, совместимость и т.д.

Не заводится UART1

Сообщение bobby » 18 мар 2014, 10:01

Всем привет! Необходимо было подцепить беспроводной модуль xBee к виртурилке. Подключился к коннекторам UART1 на гребенке, в uEnv.txt изменил флаг на uart1=on. Перезагружаю девайс, /dev/ttyS1 стал доступен. Пишу в него из своей программулины - данные попадают в ту же консоль, которую использую для отладки. То есть запускаю из консоли свою программку, и в эту же консоль мне начинают сыпаться с неё данные. Для проверки пробовал писать в /dev/ttyS0 - такой же результат (как и должно быть).
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение Gol » 18 мар 2014, 10:14

Аватара пользователя
Gol
 
Сообщения: 507
Зарегистрирован: 17 фев 2012, 01:44
Откуда: Тула-Свободный-Щёкино-Тула-Москва

Re: Не заводится UART1

Сообщение bobby » 18 мар 2014, 10:29

В смысле в основной? Для меня основная - и есть S0, я к ней по USB подключен. Пытаюсь писать в S1 из моей софтины, данные попадают в S0. Класс для работы с UART следующий:

#pragma once

#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

class bxmUART
{
public:

bxmUART()
{
fd = 0;
}

~bxmUART()
{

}

int setInterfaceAttribs (int speed, int parity)
{
struct termios tty;
memset (&tty, 0, sizeof tty);

if (tcgetattr (fd, &tty) != 0)
{
printf("error %d from tcgetattr", errno);
return -1;
}

cfsetospeed (&tty, speed);
cfsetispeed (&tty, speed);

tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;

tty.c_iflag &= ~IGNBRK;
tty.c_lflag = 0;

tty.c_oflag = 0;
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 0;

tty.c_iflag &= ~(IXON | IXOFF | IXANY);

tty.c_cflag |= (CLOCAL | CREAD);

tty.c_cflag &= ~(PARENB | PARODD);
tty.c_cflag |= parity;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;

if (tcsetattr (fd, TCSANOW, &tty) != 0)
{
printf("error %d from tcsetattr", errno);
return -1;
}
return 0;
}

void setBlocking (int should_block)
{
struct termios tty;
memset (&tty, 0, sizeof tty);
if (tcgetattr (fd, &tty) != 0)
{
printf("error %d from tggetattr", errno);
return;
}

tty.c_cc[VMIN] = should_block ? 1 : 0;
tty.c_cc[VTIME] = 0;

if (tcsetattr (fd, TCSANOW, &tty) != 0)
{
printf("error %d setting term attributes", errno);
}
}

void openPort(char* portname)
{
int fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);

if (fd < 0)
{
printf("error %d opening %s: %s", errno, portname, strerror (errno));
return;
}

setInterfaceAttribs(B9600, 0);
setBlocking(0);
}

void writeData(char* data, int size)
{
write(fd, data, size);
}

private:

int fd;

};

Использую его так:

int main()
{
bxmUART uartS0;
bxmUART uartS1;

uartS0.openPort("/dev/ttyS0");
uartS1.openPort("/dev/ttyS1");

uartS0.writeData("hello!\n", 7);

getchar();

uartS1.writeData("hello!\n", 7);

getchar();

return 0;
}
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение Gol » 18 мар 2014, 10:51

Аватара пользователя
Gol
 
Сообщения: 507
Зарегистрирован: 17 фев 2012, 01:44
Откуда: Тула-Свободный-Щёкино-Тула-Москва

Re: Не заводится UART1

Сообщение bobby » 18 мар 2014, 12:14

Хорошо, сейчас попробую. Кроме флага в uEnv ещё что-то нужно менять в конфигах, чтобы работать с UART1?
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение bobby » 18 мар 2014, 12:26

Попробовал слать на ttyS0 из неё же - не приходит ничего. Программно пишу в ttyS1 - в консоль пишется "hello!"
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение bobby » 18 мар 2014, 12:33

Выяснилось, что данные показываются в консоли по какой-то другой причине. Потому как название консоли, к которой подключен я - ttyGS0. Если я шеллом в неё пишу данные - они отображаются в ней, т.е. шлю сам себе. Пробовал писать также в S1 и S0 - тишина. Пробовал отправлять данные с другого передатчика и слушать на виртурилке S1 и S0 - тоже тишина.
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение Gol » 18 мар 2014, 13:28

Аватара пользователя
Gol
 
Сообщения: 507
Зарегистрирован: 17 фев 2012, 01:44
Откуда: Тула-Свободный-Щёкино-Тула-Москва

Re: Не заводится UART1

Сообщение bobby » 18 мар 2014, 13:43

Виртурилка запитана от MicroUSB. В inittab и скрипте автозапуска я прописал конфиг, чтобы отлаживать по кабелю MicroUSB. Этот виртуальный порт в системе зовется GS0. Беспроводной модуль подключен к CON28 и CON29. Команды cat /proc/tty/driver/serial и dmesg | grep ttyS показывают мне два порта - S0 и S1. Сейчас прицепились напрямую проводами от компа через переходник к виртурилке. Скорости 9600 на обоих концах. С терминала слушаю S1 (cat /dev/ttyS1), с компа шлем символы, они приходят, но по многу раз, плюс куча мусора. При этом на комп тоже что-то приходит. Пытаюсь с виртурилки слать что-то обратно (echo "hello" > /dev/ttyS1) - ничего не приходит, на принимающей стороны диод Tx не моргает.
bobby
 
Сообщения: 6
Зарегистрирован: 18 мар 2014, 09:39

Re: Не заводится UART1

Сообщение Gol » 19 мар 2014, 03:54

Аватара пользователя
Gol
 
Сообщения: 507
Зарегистрирован: 17 фев 2012, 01:44
Откуда: Тула-Свободный-Щёкино-Тула-Москва


Вернуться в Железо - заставляем работать

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 17

cron