Serial port scripting probs
Serial port scripting probs
- Subject: Serial port scripting probs
- From: ben <email@hidden>
- Date: Tue, 24 Apr 2001 19:17:16 +0200
Hi guys,
i'm trying to write a script using the SerialPort OSAX 1.2 which is supposed
to change a few settings in a ISDN adaptor. Well i tried to work through the
examples that come with the OSAX, but i'm pretty lost... my main problem:
Somehow nothing seems to happen on the serial port, though the script returns
no errors. I monitored the port with "Serial of Champions 1.1",
but all seems quiet... (contrary to my now used method of configuration via
Zterm.. there i see all the commands being sent)
I was wondering if it's that i'm using plain ASCII strings (though in Serial
of Champions you do see em in ASCII as well..), or is that ok? Or does the
string need some special "return" charakter (like in a terminal) to send it
over the port? (i did try a return at the end of the strings = nada... ;( )
Dunno, the basic routine of the script is this:
>
set port_reference to open serial port "Modemanschlu_" baud rate 57600 data bits 8 parity none stop bits 1 handshake "DTR&CTS"
>
serial port write "some AT& something stuff" to port_reference timeout 30
>
set the_result to serial port read port_reference
Even with error handlers on every corner, the script runs it's routines as
if everything went right, but actually sends nothing over the port, also the
read command returns nothing...
Any ideas & help appreciated..
--
thx,
ben
ps.: the script en detail:
=======================================
property sPort : "Modemanschlu_"
property divert_number : "some number"
property port_number : "some other number"
property set_divert_number : "at&hp995032/"
property divert_on_string : "at&hp995031/"
property divert_off_string : "at&hp995030/"
global on_off
--
set on_off to button returned of (display dialog "Rufumleitung von # " & port_number & "
nach # " & divert_number buttons {"abbrechen", "einschalten", "ausschalten"} default button 1 with icon caution)
if on_off = "abbrechen" then
quit
else
try
set port_reference to open serial port "Modemanschlu_" baud rate 57600 data bits 8 parity none stop bits 1 handshake "DTR&CTS"
if on_off = "einschalten" then
set_divert_on(set_divert_number, divert_number, port_reference, divert_on_string, port_number)
else
set_divert_off(port_reference, divert_off_string, port_number)
end if
delay 2
set the_result to serial port read port_reference
display dialog ("Ergebnis: " & the_result) buttons {"Ok"} default button 1 with icon caution
close serial port port_reference
on error errmsg number errNum
display dialog "ERROR: " & errmsg & " --- " & errNum
if port_reference is not "" then
close serial port port_reference
end if
end try
end if
--
on set_divert_on(set_divert_number, divert_number, port_reference, divert_on_string)
try
serial port write (set_divert_number & port_number & "=" & divert_number) to port_reference timeout 120
serial port write (divert_on_string & port_number) to port_reference timeout 120
on error errmsg number errNum
display dialog "ERROR: " & errmsg & " --- " & errNum
end try
end set_divert_on
on set_divert_off(port_reference, divert_off_string)
try
serial port write (divert_off_string & port_number) to port_reference timeout 30
on error errmsg number errNum
display dialog "ERROR: " & errmsg & " --- " & errNum
end try
end set_divert_off