US Robotics USR803510 Guide de l'utilisateur Page 83

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 158
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 82
Revision: 1.00 Copyright 2015 U.S. Robotics Corporation 83 | P a g e
Note:
By default the TX and RX of the RS485 connection are disabled. So you have to enable them
before you can start using the RS485 port. (You can enable this by using the DE and RE
signals). For a 2 wire interface (=half duplex) you should of course only enable one direction
at the same time.
Below an example of how to do this in your code.
(The example shows how to activate both DE and RE)
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
# include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
/**************************************************************************
* Manifest Constants
**************************************************************************/
#ifndef TIOCM_OUT1
#define TIOCM_OUT1 0x2000
#define TIOCM_OUT2 0x4000
#endif
#define TIOCM_RE TIOCM_OUT1
#define TIOCM_DE TIOCM_OUT2
/*************************************************************************/
int main (void)
{
int fd = open("/dev/ttySP4",O_RDWR || O_NONBLOCK);
if (fd < 0) { printf("failed to pen device\n"); return 0; }
int status, err;
/* switch on RS485 TRANSMIT buffer and RECEIVE buffer */
ioctl(fd, TIOCMGET, &status);
status |= (TIOCM_DE | TIOCM_RE);
if ((err = ioctl(fd, TIOCMSET, &status)))
{
printf("ioctl error 0x%x, errno 0x%x, status %x",err, errno, status);
}
close(fd);
return 0;
}
Vue de la page 82
1 2 ... 78 79 80 81 82 83 84 85 86 87 88 ... 157 158

Commentaires sur ces manuels

Pas de commentaire