Sponsored Content
Top Forums Programming How to set the DSR pin using a C Code Post 302079985 by Corona688 on Friday 14th of July 2006 10:30:28 AM
Old 07-14-2006
Good question. It's very hard to know where to look to find this out.
Code:
#include <sys/ioctl.h>
#include <termios.h>
#include <linux/serial.h> 
#include <fcntl.h>
#include <stdio.h>

int setdtr (int fd, int on)
{
  int controlbits = TIOCM_DTR;
  if(on)
    return(ioctl(tty_fd, TIOCMBIC, &controlbits));
  else
    return(ioctl(tty_fd, TIOCMBIS, &controlbits));
} 

int main()
{
  const char *dev="/dev/ttyS0";
  int fd=open(dev,O_RDWR);
  if(fd<0)
  {
    fprintf(stderr,"Couldn't open %s\n",dev);
    return(1);
  }

  fprintf(stderr,"Setting DTR\n");
  setdtr(fd,1);

  // Pause for three seconds
  sleep(3);

  fprintf(stderr,"Clearing DTR\n");
  setdtr(fd,0);

  close(fd);
  return(0);
}

No special libraries should be needed.

For more detail refer to the source I found here
 

8 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Pin to desktop

Hello everybody! I need some help. Is there a way to pin a window to the desktop in Linux? I have a list of tasks in Calc. And I want the window of Calc to be always before my eyes, so that it sort of reminds me of my tasks. The window must be «stuck» to the desktop, and when I click the... (0 Replies)
Discussion started by: alex777
0 Replies

2. Programming

How to read the CTS and DSR of RS232 in Unix using C language?

Hello to all Gurus out there, Could you show me a source code in Unix platform using C language. I want to read the status or voltage level of the DSR and CTS. Thanks a lot, Swing5 (2 Replies)
Discussion started by: Swing5
2 Replies

3. Programming

Need pin generation code

Hi Can any one tell me from where can i get the code/library(c/c++(Sun)) for PIN generation. Actually i need to generate a new PIN for the user in case sombody reset his PIN. Thanks in Advance. (1 Reply)
Discussion started by: unisuraj
1 Replies

4. Programming

regarding adding fields to DSR protocol in ns2.34

hi i am student doing project in ns2.34. i hav to add field in route cache and packet of DSR routing protocol. which files hv to be changed...pl help me (1 Reply)
Discussion started by: khubalkar
1 Replies

5. Homework & Coursework Questions

regarding adding fields to DSR protocol in ns2.34

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: want to add field to route cache and packet of DSR routing protocol in ns2.34, add field, DSR package in ns2.34... (2 Replies)
Discussion started by: khubalkar
2 Replies

6. IP Networking

How to configure RHEL6 to support Aleton 4408 in DSR mode?

Dears How to configure RHEL6 to support Aleton 4408 in DSR(Direct Server Return) mode We have config Aleton 4408 + Windows 2008R2 then Windows set loopback interface with VIP. the exec the following command in CMD netsh interface ipv4 set interface "net" weakhostreceive=enabled netsh... (0 Replies)
Discussion started by: nnnnnnine
0 Replies

7. IP Networking

Source IP address field in RREP on DSR routing

Hello I have a question about routing in MANET using Dynamic Source Routing protocol. IN RFC4728 (DSR) in section "IP fields" of RREP (Route Reply) packet we have this: ok. I read in several books and also in rfc4728 that: when a source node (node that initiate route discovery process)... (1 Reply)
Discussion started by: acu281
1 Replies

8. Shell Programming and Scripting

Pin code counter

hello i wanted to see if anyone can analyze the following code and see where the error lies. it is supposed to echo the current date and start counting from 0000-9999 and show the approximate range that it is at. here is a pic of what the output should look like:... (3 Replies)
Discussion started by: Kooftness
3 Replies
PROP_SEND_IOCTL(3)					   BSD Library Functions Manual 					PROP_SEND_IOCTL(3)

NAME
prop_array_send_ioctl, prop_array_recv_ioctl, prop_dictionary_send_ioctl, prop_dictionary_recv_ioctl, prop_dictionary_sendrecv_ioctl -- Send and receive propertly lists to and from the kernel using ioctl SYNOPSIS
#include <prop/proplib.h> int prop_array_send_ioctl(prop_array_t array, int fd, unsigned long cmd); int prop_array_recv_ioctl(int fd, unsigned long cmd, prop_array_t *arrayp); int prop_dictionary_send_ioctl(prop_dictionary_t dict, int fd, unsigned long cmd); int prop_dictionary_recv_ioctl(int fd, unsigned long cmd, prop_dictionary_t *dictp); int prop_dictionary_sendrecv_ioctl(prop_dictionary_t dict, int fd, unsigned long cmd, prop_dictionary_t *dictp); DESCRIPTION
The prop_array_send_ioctl, prop_array_recv_ioctl, prop_dictionary_send_ioctl, prop_dictionary_recv_ioctl, and prop_dictionary_sendrecv_ioctl functions implement the user space side of a protocol for sending property lists to and from the kernel using ioctl(2). RETURN VALUES
If successful, functions return zero. Otherwise, an error number is returned to indicate the error. EXAMPLES
The following (simplified) example demonstrates using prop_dictionary_send_ioctl() and prop_dictionary_recv_ioctl() in an application: void foo_setprops(prop_dictionary_t dict) { int fd; fd = open("/dev/foo", O_RDWR, 0640); if (fd == -1) return; (void) prop_dictionary_send_ioctl(dict, fd, FOOSETPROPS); (void) close(fd); } prop_dictionary_t foo_getprops(void) { prop_dictionary_t dict; int fd; fd = open("/dev/foo", O_RDONLY, 0640); if (fd == -1) return (NULL); if (prop_dictionary_recv_ioctl(fd, FOOGETPROPS, &dict) != 0) return (NULL); (void) close(fd); return (dict); } The prop_dictionary_sendrecv_ioctl function combines the send and receive functionality, allowing for ioctls that require two-way communica- tion (for example to specify arguments for the ioctl operation). ERRORS
prop_array_send_ioctl() and prop_dictionary_send_ioctl() will fail if: [ENOMEM] Cannot allocate memory [ENOTSUP] Not supported prop_array_recv_ioctl() and prop_dictionary_recv_ioctl() will fail if: [EIO] Input/output error [ENOTSUP] Not supported In addition to these, ioctl(2) errors may be returned. SEE ALSO
prop_array(3), prop_dictionary(3), proplib(3), prop_copyin_ioctl(9) HISTORY
The proplib property container object library first appeared in NetBSD 4.0. BSD
January 21, 2008 BSD
All times are GMT -4. The time now is 06:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy