kansaschuck has asked for the wisdom of the Perl Monks concerning the following question:

I'm playing around in the serial (rs232) connected devices. I would like Perl to handle communication with the serial port. The builder of my electronics says the they have a nice .DLL (SSC-5.DLL) that will simplify my coding. So, if I understand things right Perl needs to call these functions or connect to the .DLL. (I have the .DLL in c\windows\system. Does anyone have some good examples of this time of code/call? advice? more doc below.
Just three functions make up the Mini SSC DLL: * SSC_OPEN(port,baudrate) --Set up the comm port for the specified + baud rate, initialize memory for the DLL, and start a background thr +ead (task) that will update the Mini SSC via the serial port. * SSC_MOVE(servo,position) --Move servo to position Note: the DLL +supports servo numbers 0-31 only. * SSC_CLOSE() --Shut down the background thread and close the seri +al port. http://www.seetron.com/pdf/ssc2_mnl.pdf

Replies are listed 'Best First'.
Re: Perl calling my.DLL for serial port work.
by Corion (Patriarch) on Feb 03, 2008 at 15:59 UTC

    You want to use Win32::API for accessing the code in the DLL. Most likely, the signatures will be:

    1. my $SSC_OPEN = Win32::API->new( 'ssc-5', 'SSC_OPEN', 'II', 'I', ); sub SSC_OPEN { $SSC_OPEN->Call(@_); };
    2. my $SSC_MOVE = Win32::API->new( 'ssc-5', 'SSC_MOVE', 'II', 'I', ); sub SSC_MOVE { $SSC_MOVE->Call(@_); };
    3. my $SSC_CLOSE = Win32::API->new( 'ssc-5', 'SSC_CLOSE', '', '', ); sub SSC_CLOSE { $SSC_CLOSE->Call(@_); };
      Thanks Corion, that's a great start. I'm working thru some problems at the moment. 'cant find new... maybe you forgot to load winapi.' Doing some research on the winapi load. kc

        Most of the time, it really helps if you copy and paste the exact error message you're getting, together with the code (a really small, self-contained example) that causes this.

        My guess is that you're just missing the following line at the top of your program:

        use Win32::API;

        Also see the use keyword.