user2829
user2829

Reputation: 461

Data Transfer Between Serial Port and Device using Perl Win32::SerialPort module

I am developing a Perl script to transfer data between Bluetooth firmware (BT connected through USB) and test equipment (connected through a serial port). I am using the Perl module Win32::SerialPort. I can get data from Equipment in special ASCII format ( ☻ Black Smiley..♥ Black heart...). When I convert it back to hex I get the opcode that my firmware can process. In return BT firmware sends a command complete opcode back.

Problem starts here... When I try to write back to Serial Port using $PortObj->write(opcode(hex)) the test equipment does not recognize it. What should I do here?

Upvotes: 1

Views: 2215

Answers (1)

user2829
user2829

Reputation: 461

ok I guess pack function in perl works for me :)..

@input=(0x04,0x0e,0x04,0x01,0x03,0x0c,0x00);

$ascii = pack("C*", @input);

print "the value is $ascii";

$PortObj->write($ascii)|| die "Can't write to $PortObj: $^E\n";

Upvotes: 2

Related Questions