No such thing as a small change | |
PerlMonks |
Reading Data from a Serial Port using Win32::SerialPortby c4onastick (Friar) |
on Nov 19, 2010 at 22:22 UTC ( [id://872602]=perlquestion: print w/replies, xml ) | Need Help?? |
c4onastick has asked for the wisdom of the Perl Monks concerning the following question: I'm having trouble reading data from a serial port using Win32::SerialPort. I'm working on writing a control program for a couple of syringe pumps. I've been able to successfully use the manufacturer's program to talk to the pump (so I'm pretty sure the pump is working properly), and I've been able to use their raw command syntax with PuTTY and there I can see the messages sent back from the pump. Unfortunately, the things I need to do are a little too sophisticated for the manufacturer's program (or at least it would take less work to write my own program than to try to get the manufacturer's program to do what I want). I've been digging through the Win32::SerialPort documentation and searching the web, but I don't seem to be getting any closer unfortunately. Here's what I've been using so far for my settings:
Aside from the handshake, parity, databits, etc., I figured out the rest of these settings by comparing the initialization of my script with the start up of the manufacturer's program using PortMon. The basic settings, (parity, stopbits, etc.) I got from the manufacturer's documentation on the protocol. The problem is this: whenever I write to the serial port, the subsequent read just echos back the command. For example, if I try to read right after the write:
This should yield "CV02.00.A", but instead I get nothing ($VAR1 = '';) Introducing a small wait gets me something, but it's just the "aU" command echoed back:
The response I get back is $VAR1 = 'aU\n';. (The '\n' is actually printed as a new line, I just added it here so as to keep this post pretty.) I've tried the tied version with no luck:
Result: aU The straight "read" method doesn't help either:
Result: aU Anyone encountered this problem before? Any thoughts on what I might try? Thanks in advance for your help!
Back to
Seekers of Perl Wisdom
|
|