NewtownGuy
Technical User
Hello,
I'm trying to control a robot from a Fedora Core 3 machine running Apache 2. I have a web page on that machine that, when clicked, runs a cgi-script on that machine that is trying to send a binary file out the COM1 / ttyS0 port out that same machine.
I have several problems:
1) for test purposes (not using the script), the command I'm using to send a file out the COM port is not working. Here are two things I've tried:
[root@-001 log]# cp test1.bin /dev/ttyS0
cp: overwrite `/dev/ttyS0'? n
[root@-001 log]# cp test1.bin >/dev/ttyS0
cp: missing destination file
Try `cp --help' for more information.
[root@-001 log]#
Here's a fragment from my actual perl script:
2) I've used setserial /dev/ttyS0 baud_rate 9600 to configure the COM port. Is this the proper way to do it ? Do I need to put anything in a startup script so it's always active on boot ?
3) Do I need to set any permissions to write to a COM port ? Do I need to write to a file first, and then copy the entire file (< 10 bytes) to the COM port ?
4) It's important that the entire command string be sent as a contiguous set of bytes without any null bytes in the middle. Are there any timing problems doing this from a perl script that composes and prints each character ? Or, do I need to write the entire string to a file as a buffer, and then write the file to the COM port ?
I know the connection to the robot is good, that the robot is good, and that a test command file are good because I've tested them from a COM port on a Windows machine using the same binary file I've used in Linux.
Thank you.
-- NewtownGuy
I'm trying to control a robot from a Fedora Core 3 machine running Apache 2. I have a web page on that machine that, when clicked, runs a cgi-script on that machine that is trying to send a binary file out the COM1 / ttyS0 port out that same machine.
I have several problems:
1) for test purposes (not using the script), the command I'm using to send a file out the COM port is not working. Here are two things I've tried:
[root@-001 log]# cp test1.bin /dev/ttyS0
cp: overwrite `/dev/ttyS0'? n
[root@-001 log]# cp test1.bin >/dev/ttyS0
cp: missing destination file
Try `cp --help' for more information.
[root@-001 log]#
Here's a fragment from my actual perl script:
Code:
# Open output file and redirect to COM port
open(OUT, ">/dev/ttyS0") or die "Can't open : ttyS0 $!\n";
binmode(OUT);
flock (OUT, 2); # Lock the file to protect it from writing by others
# Output one fixed 8-bit value whose value is 0xFF
print OUT chr(hex('FF'));
2) I've used setserial /dev/ttyS0 baud_rate 9600 to configure the COM port. Is this the proper way to do it ? Do I need to put anything in a startup script so it's always active on boot ?
3) Do I need to set any permissions to write to a COM port ? Do I need to write to a file first, and then copy the entire file (< 10 bytes) to the COM port ?
4) It's important that the entire command string be sent as a contiguous set of bytes without any null bytes in the middle. Are there any timing problems doing this from a perl script that composes and prints each character ? Or, do I need to write the entire string to a file as a buffer, and then write the file to the COM port ?
I know the connection to the robot is good, that the robot is good, and that a test command file are good because I've tested them from a COM port on a Windows machine using the same binary file I've used in Linux.
Thank you.
-- NewtownGuy