in reply to Re: Using Device::SerialPort
in thread Using Device::SerialPort

HyperTerminal is a Windows program, but your code seems to be for a *NIX system? Is this two different computers? Are you sure your serial device works on the *NIX system?

If you're sure about the baud rate and the other settings (including flow control, handshake, etc.), then it's hard to guess what is going on without knowing the details of your software & hardware set-up - at least I'm at a loss at the moment, perhaps someone else has seen a similar problem. It might also help if you describe what kind of a device you're talking to, whether it is a "real" hardware serial port or a USB adapter, etc.

some ACK response

Could you perhaps be more specific, like show a short example session?

To pick up on some of the things you wrote earlier:

How can i really tell whether my command did go through OK.

The only way to really tell what's physically going on is to look at the signal on the wires with a logic analyzer or oscilloscope. On the PC side, in my experience it's usually a matter of making sure that there's only one software trying to access the port at once, and getting all of the settings right.

I know my response to the serial port is not what I am seeing here.

How did you determine this?

Replies are listed 'Best First'.
Re^3: Using Device::SerialPort
by hardy004 (Novice) on Feb 11, 2015 at 02:31 UTC

    Forgot to mention that I am using cygwin on Windows Computer. The device is a real hardware whose serial port is where I am trying to send some data & read the response back. So what I do is send commands from Hyper-terminal to the hardware using the serial port. For the command that I send, I get some response back. This is the why I am aware of what response I am looking for. Now I go back into cygwin perl environment & using Device::SerialPort module I attempt to send the same command. When i try reading the response, I see those scribbled characters. I have my framework developed in perl & communicating to serial port is just a small part of it. Hence the reason I am trying to incorporate perl's Device::SerialPort into my perl framework. Are you aware of any other method to open up Serial Port in perl & send commands ? Please let me know, if you have any more questions & thanks for your help.

      Since you are running on Windows, it's possible that Cygwin's Perl could be able use Win32::SerialPort. The syntax of Win32::SerialPort and Device::SerialPort will be very similar.

      It's been a long time since I last used Cygwin, but since it's "just" a compatibility/emulation layer, I wouldn't be surprised at all if there were issues with its handling of serial ports and/or the interaction of Windows, Cygwin and Device::SerialPort. Have you tried accessing the serial port from inside the Cygwin environment, for example via screen? Also, and this is a complete stab in the dark, perhaps the baud rate setting is getting messed up somehow, and you could try setting the default baud rate of the port in the Windows Control Panel in the Device Manager.

      If you're not entirely fixed on Cygwin, as a possible alternative, Win32::SerialPort should work under Strawberry Perl (I have seen at least one report that someone had to use the 32-bit edition of Strawberry Perl even on a 64-bit Windows, though).

      You asked about other alternatives: Yes, there are some more "low-level" ways of opening and communicating with the serial port in Perl, but in my experience those can sometimes become so tricky to get right that it's probably better to first try to get Win32::SerialPort or Device::SerialPort working.