I have to unplug and plug my USB device every time to communicate :(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashishchauhan
    New Member
    • Aug 2009
    • 2

    I have to unplug and plug my USB device every time to communicate :(

    I am using a linux machine with an USB port and I have to communicate with a temperature controller which has an UART port and for this I am using a USB to UART Serial Adapter.
    port name on my machine is /dev/ttyUSB0
    Code:
    $port = "/dev/ttyUSB0";
    open(SERIALPORT,"+>$port") || die("ERROR SENDING DATA\n");
    SERIALPORT->autoflush();
    
    ## in between I am sending data 
    
    print $FILEHANDLE $data;
    and receiving back from that temperature controller ##

    after all that process I am closing that file handle.
    Code:
    close(SERIALPORT);
    code is working fine one time . I am getting correct result .

    but when I am trying to run the script second time then it hands at the step when I am sending data to temperature controller
    Code:
     
    print $FILEHANDLE $data;
    and for this I have to unplug and plug that USB serial adapter again.after that it is working fine.

    I am unable to find out what is the problem.
    Can u people figure out what may be the possible reasons for it.

    Thanks for your reply in advance.
    Last edited by numberwhun; Aug 20 '09, 01:04 PM. Reason: Please use code tags!
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Originally posted by ashishchauhan
    I am using a linux machine with an USB port and I have to communicate with a temperature controller which has an UART port and for this I am using a USB to UART Serial Adapter.
    port name on my machine is /dev/ttyUSB0

    $port = "/dev/ttyUSB0";
    open(SERIALPORT ,"+>$port") || die("ERROR SENDING DATA\n");
    SERIALPORT->autoflush();

    ## in between I am sending data

    print $FILEHANDLE $data;

    and receiving back from that temperature controller ##

    after all that process I am closing that file handle.
    close(SERIALPOR T);

    code is working fine one time . I am getting correct result .

    but when I am trying to run the script second time then it hands at the step when I am sending data to temperature controller
    print $FILEHANDLE $data;

    and for this I have to unplug and plug that USB serial adapter again.after that it is working fine.

    I am unable to find out what is the problem.
    Can u people figure out what may be the possible reasons for it.

    Thanks for your reply in advance.
    What is the filehandle you are using? Is it $FILEHANDLE or SERIALPORT

    Comment

    • ashishchauhan
      New Member
      • Aug 2009
      • 2

      #3
      oh sorry . it is SERIALPORT .

      Comment

      Working...