cat /sys/devices/bone_capemgr.9/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART4
10: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART4-RTSCTS
cat /proc/tty/driver/OMAP-SERIAL
serinfo:1.0 driver revision:
0: uart:OMAP UART0 mmio:0x44E09000 irq:72 tx:345 rx:0 RTS|CTS|DTR|DSR
4: uart:OMAP UART4 mmio:0x481A8000 irq:45 tx:61355 rx:1 brk:1 RTS|DTR|DSR
struct serial_rs485 rs485conf;
rs485conf.flags |= SER_RS485_USE_GPIO;
rs485conf.gpio_pin = GPIO0_9;‘SER_RS485_USE_GPIO’ was not declared in this scope
rs485conf.flags |= SER_RS485_USE_GPIO;
‘struct serial_rs485’ has no member named ‘gpio_pin’
rs485conf.gpio_pin = GPIO0_9;
‘GPIO0_9’ was not declared in this scope
rs485conf.gpio_pin = GPIO0_9;
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
When I tried to use:struct serial_rs485 rs485conf;
rs485conf.flags |= SER_RS485_USE_GPIO;
rs485conf.gpio_pin = GPIO0_9;
I got error from gcc that it does not know those macros:‘SER_RS485_USE_GPIO’ was not declared in this scope
rs485conf.flags |= SER_RS485_USE_GPIO;
‘struct serial_rs485’ has no member named ‘gpio_pin’
rs485conf.gpio_pin = GPIO0_9;
‘GPIO0_9’ was not declared in this scope
rs485conf.gpio_pin = GPIO0_9;
In the Debian image from Robert C Nelson, the patch rs485 is already included.
1 #include <linux/types.h>
2
3
4 struct serial_rs485 {
5 __u32 flags; /* RS485 feature flags */
6 #define SER_RS485_ENABLED (1 << 0) /* If enabled */
7 #define SER_RS485_RTS_ON_SEND (1 << 1) /* Logical level for
8 RTS pin when
9 sending */
10 #define SER_RS485_RTS_AFTER_SEND (1 << 2) /* Logical level for
11 RTS pin after sent*/
12 #define SER_RS485_RTS_BEFORE_SEND (1 << 3)
13 #define SER_RS485_USE_GPIO (1 << 5)
14 //#define SER_RS485_RX_DURING_TX (1 << 4)
15 __u32 delay_rts_before_send; /* Delay before send (milliseconds) */
16 __u32 delay_rts_after_send; /* Delay after send (milliseconds) */
17 // __u32 padding[5]; /* Memory is cheap, new structs
18 __u32 gpio_pin; /* GPIO Pin Index */
19 __u32 padding[4]; /* Memory is cheap, new structs
20 are a royal PITA .. */
21 };
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include "serial.h"
//#include <include/uapi/linux/serial.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int fd = open("/dev/ttyO4", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0)
{
perror("Error opening tty!");
return 1;
}
struct serial_rs485 rs485conf;
rs485conf.flags |= SER_RS485_ENABLED;
rs485conf.flags |= SER_RS485_USE_GPIO;
rs485conf.gpio_pin = 9;
rs485conf.flags |= SER_RS485_RTS_ON_SEND;
rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);
rs485conf.delay_rts_before_send = 0;
rs485conf.delay_rts_after_send = 0;
if (ioctl (fd, TIOCSRS485, &rs485conf) < 0)
{
perror("Bad ioctl");
}
struct termios ttyc;
tcgetattr(fd, &ttyc);
cfsetospeed(&ttyc, B9600);
cfsetispeed(&ttyc, B9600);
ttyc.c_cflag &= ~CRTSCTS;
ttyc.c_cflag |= CS8 | CLOCAL | CREAD;
ttyc.c_cflag |= CRTSCTS;
ttyc.c_cc[VMIN] = 1;
ttyc.c_cc[VTIME] = 5;
tcsetattr(fd, TCSANOW, &ttyc);
char data = 0xAA;
int i = 0;
while(i < 10000)
{
if(write(fd, &data, 1) < 1)
{
perror("Error sending char");
break;
}
i++;
}
if (close (fd) < 0)
{
perror("Error closing tty!");
return 1;
}
return 0;
}Normally If you look at the log (dmsg) you should see a line rs485 something. It's a printk that I show when the ioctl work.
And of course you have to configure the pin correctly = pin mode for TX, rx, gpio.
Normally If you look at the log (dmsg) you should see a line rs485 something. It's a printk that I show when the ioctl work.
[ 222.055685] gpio_request: gpio-9 (RS485 TXE) status -16
[ 222.055730] omap_uart 481a8000.serial: Could not request GPIO 9 : -16
Yes, I can see 'rs485 v1.1'. The python code still works fine out of the box. C code Rx and Tx lines work OK but RTS still does nothing.
When I exported the GPIO9 by hand, dmesg got:That means that 485 kernel support works. Without manually exporting it says just "[ 537.089146] rs485 v1.1" and does nothing.[ 222.055685] gpio_request: gpio-9 (RS485 TXE) status -16
[ 222.055730] omap_uart 481a8000.serial: Could not request GPIO 9 : -16
BUT now I've discovered something strange with logical level flags in struct serial_rs485, maybe I'm using different header or maybe I don't understand it correctly.
When I changed the SER_RS485_RTS_AFTER_SEND to 0 and SER_RS485_RTS_ON_SEND to 0, it started working fine.
That means, when sending data, RTS goes HIGH, after sending, it goes immediately LOW , that means,
I expected setting ON_SEND to 1 and AFTER_SEND to 0, but with this setting it just changed from LOW to LOW.
...
Hello, everyone, I just notify something with the RS485 :I've made a test programm, and in this programm, I'm sending all the time one byte.With the oscilloscope, I can see that there is a delay between each frame : 100ms .Do you have the same thing ?Micka,
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/128d1fae-46ac-4e2d-a759-1cb1568f443c%40googlegroups.com.