Applescript Error -609

Hi Folks,

has anyone a clue how to eliminate the -609 Connection is invalid error?

I thought this is maybe a result because the Connection is crashing with the onIdle - but
altough I am starting the Idle Handler after the Connection is starting I will get the -609 Connection is invalid
message…

Anybody there who knows how to solve this?

Thanks for your support and help…

Stefan

Stefan,

I think it would be helpful if you could post your code with an explanation of how your interface is laid out and supposed to work.

Aside from that, and I may be incorrect in this, but it seems that it is telling you that some of your interface connections to the script objects are not quite correct. I usually put ‘display dialog’ something in the various blocks of code to make sure they are comming up when I expect them to. This can help narrow where the problem is coming from. Is everything working as expected before the error? What is supposed to happen after the error? Are variables being passed correctly? Are your variables and any other information that is being passed in the correct form? (text variable for text manipulation, numbers for numbers, file references for files and such).

PreTech

Hi Pretech,

thanks for your reply! I know it would be helpful to post some parts of my script - I will do this right now:

I have put some display dialogs and see that all of the variables are passed correct…



property init_run : true

on clicked theObject

if name of theObject is "Connect" then
tell window "main"
set PopupButtonItem to modem_display
end tell

set theMatrixItem to title of current cell of matrix "theMatrix" of tab view item "Setting" of tab view "tab" of window "main

if (PopupButtonItem is "Web'n'walk Box compact") and (theMatrixItem is "HSDPA Internet") then
tell application "Internet Connect"
set configName to "Huawei Mobile"
set currentStatus to status of configuration configName
connect PPP configuration 1 to telephone number "gprsinternet"
quit
end tell
end if


delay 1
set init_run to false

end clicked

on idle theObject

if init_run then

else

all the idle stuff...

return 1
end idle


Maybe the problems are on the "connect ppp configuration 1 to telephone number “gprsinternet”…

Thanks for your help!

Stefan

Stefan,

I cannot really tell much from this part of your script. It seems that you believe that the -609 connection invalid error has something to do with your internet connection, but it doesn’t. It has to do with your script objects and their connections to each other (I believe, I may be wrong, but I’ve had this error before and it has always had to do with my coding).

When you run your app, does it get to where it activates the Internet Connect app?

PreTech

Well, after saying this, the -609 error is an Operating System error. Maybe, I’m thinking of the -10003 error. However, the question still is, is Internet Connect activating? Try commenting out the line that you believe is the error and see if it still occurs.

Hi Pretech,

thanks for your continious support! The Connection is comming to life - the idle handler is not responding from the first moment on, but it is connecting…

I have put an delay of 5 seconds after the onclick and now its going to be a little better… but from time to time I get the same error…

I have attached the source of my programm - if you have a little time :slight_smile: then I will be glad if you can take a look at it…

Thanks and Best regards,

Stefan


-- Web'n'walk Manager MacOS.applescript
-- Web'n'walk Manager MacOS

--  Created by Stefan Lehrner on 11/10/06
--  Copyright 2006 T-Mobile.at.

property init_run : true
property notHidden : true

on launched theApplication
	
	--Anzeige SplashScreen
	
	
	
	--Passwort abfrage - es wird das Systempasswort abgefragt!
	(*
	try
		do shell script "" with administrator privileges
	on error e
		if e contains ("incorrect" as Unicode text) then
			quit theApplication
			return
		end if
	end try
	*)
	-- Buttons setzen!
	
	set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to true
	set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to false
	set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 1
	--Modemabfrage - dieser Block muss identisch mit dem OnClick Handler sein!
	
	set modem_check to serialport list
	if modem_check contains "/dev/cu.HUAWEIMobile-Modem" then
		set modem to "/dev/cu.HUAWEIMobile-Modem"
		set modem_display to "Web'n'walk Box compact"
	else if modem_check contains "/dev/cu.HUAWEIMobile-Diag" then
		set modem to "/dev/cu.HUAWEIMobile-Diag"
		set modem_display to "Kein gültiges Modem gefunden"
	else if modem_check contains "/dev/cu.modem" then
		display dialog "Kein Modem angeschlossen - bitte stecken Sie das Gerät an und starten Sie das Programm neu" buttons {"OK"} default button 1
		quit theApplication
		delay 1
		run theApplication
	end if
	-- Hier wird das Modem angezeigt
	set contents of text field "device_con" of tab view item "Connection" of tab view "tab" of window "main" to modem_display
	
	-- Hier wird der Provider gecheckt
	
	set portRef to serialport open modem
	
	if portRef is equal to -1 then
		display dialog "Bitte starten Sie das Programm neu!" buttons {"OK"} default button 1
		quit theApplication
	else
		--delay 1
		set provider to "at+cops?" & return
		serialport write provider to portRef
		delay 1
		set provider_show to serialport read portRef for 35
		serialport close portRef
	end if
	if provider_show contains "SIM failure" then
		serialport close portRef
		display dialog "Bitte SIM Card einlegen und neu starten" buttons {"OK"} default button 1
		quit theApplication
		delay 1
	else if provider_show contains "SIM busy" then
		serialport close portRef
		display dialog "SIM Card beschäftigt bitte neu starten" buttons {"OK"} default button 1
		quit theApplication
		delay 1
	else
		
		set tid to AppleScript's text item delimiters
		set AppleScript's text item delimiters to "\"" -- again, quotes escaped
		set Q to text item 2 of provider_show
		set AppleScript's text item delimiters to tid
		
		if Q is not equal to "T-Mobile A" then
			set provider to "at+cops?" & return
			serialport write provider to portRef
			--delay 1
			set provider_show to serialport read portRef for 35
			serialport close portRef
			set tid to AppleScript's text item delimiters
			set AppleScript's text item delimiters to "\"" -- again, quotes escaped
			set Q to text item 2 of provider_show
			set AppleScript's text item delimiters to tid
		end if
	end if
	set contents of text field "provider" of tab view item "Connection" of tab view "tab" of window "main" to Q
	
	-- Roaming Infos checken - National Roaming is not allowed...
	
	if Q contains "one" then
		try
			tell current application
				display dialog "National Roaming mit " & Q & " ist nicht gestattet - bitte starten Sie das Programm neu" buttons {"OK"} default button 1
				quit theApplication
				delay 1
				launch theApplication
			end tell
		end try
	else if Q contains "3" then
		try
			tell current application
				display dialog "National Roaming mit " & Q & " ist nicht gestattet - bitte starten Sie das Programm neu" buttons {"OK"} default button 1
				quit theApplication
				delay 1
				launch theApplication
			end tell
		end try
	else if Q contains "A1" then
		try
			tell current application
				display dialog "National Roaming mit " & Q & " ist nicht gestattet - bitte starten Sie das Programm neu" buttons {"OK"} default button 1
				quit theApplication
				delay 1
				launch theApplication
			end tell
		end try
	else if Q does not contain "T-Mobile A" then
		try
			tell current application
				display dialog "Möchten Sie sich mit " & Q & " verbinden? Dies kann zu zusätzlichen Kosten führen" buttons {"Cancel", "Ja"} default button "Cancel"
				set the requested_status to the button returned of the result
			end tell
		on error number -128
			quit theApplication
		end try
	end if
	
	
	
	
	--Hier wird der Pegel des netzwerkes gecheckt
	set portRef1 to serialport open modem
	if portRef1 is equal to -1 then
		display dialog "Bitte starten Sie das Programm neu!" buttons {"OK"} default button 1
		quit theApplication
	else
		--delay 1
		set foundOffset to 0
		set pegel to "at+CSQ" & return
		serialport write pegel to portRef1
		delay 1
		set pegel_show to serialport read portRef1
		
		set AppleScript's text item delimiters to the ":"
		set the pegel_show to 2nd text item of pegel_show
		set AppleScript's text item delimiters to the ","
		set the pegel_show to 1st text item of pegel_show
		--	display dialog pegel_show
		
		set pegel_show to pegel_show as number
		serialport close portRef1
	end if
	
	if pegel_show is less than or equal to 10 then
		set content of control "pegel_signal" of tab view item "Connection" of tab view "tab" of window "main" to 1
	else if pegel_show is less than or equal to 15 then
		set content of control "pegel_signal" of tab view item "Connection" of tab view "tab" of window "main" to 2
	else if pegel_show is less than or equal to 20 then
		set content of control "pegel_signal" of tab view item "Connection" of tab view "tab" of window "main" to 3
	else if pegel_show is less than or equal to 25 then
		set content of control "pegel_signal" of tab view item "Connection" of tab view "tab" of window "main" to 4
	else if pegel_show is less than or equal to 35 then
		set content of control "pegel_signal" of tab view item "Connection" of tab view "tab" of window "main" to 5
	end if
	
	
	-- Hier wird die Telefonnummer abgefragt:
	
	set portRef1 to serialport open modem
	if portRef1 is equal to -1 then
		display dialog "Bitte starten Sie das Programm neu" buttons {"OK"} default button 1
		quit theApplication
	else
		--delay 1
		set foundOffset to 0
		set own_number to "at+cnum" & return
		serialport write own_number to portRef1
		delay 1
		set number_show to serialport read portRef1
		set AppleScript's text item delimiters to the "\""
		set the number_show to 4th text item of number_show
		set contents of text field "pegel" of tab view item "Connection" of tab view "tab" of window 1 to number_show
		serialport close portRef
	end if
	
	-- Fenster schließen
	
	--set visible of window "startup" to false
	
	if notHidden is "false" then
		hide window "startup"
	end if
	
	
end launched

on idle theObject
	
	if init_run then
		--display dialog "here"
	else
		--display dialog "here!"
		--Anzeige Onlinezeit
		tell application "Internet Connect"
			set time_conn to seconds connected of status as string
		end tell
		
		set numSeconds to time_conn mod 60
		set temp to time_conn - numSeconds
		set numMinutes to temp div 60
		set numMinutes to numMinutes mod 60
		set temp to (numMinutes * 60) + numSeconds
		set temp to time_conn - temp
		set numHours to temp div 3600
		if numHours < 10 then set numHours to "0" & numHours
		if numMinutes < 10 then set numMinutes to "0" & numMinutes
		set finalTime to numHours & ":" & numMinutes & ":" & numSeconds as string
		
		
		-- Statusanzeige (Internet)
		
		tell application "Internet Connect"
			set con_status to state of status as string
		end tell
		
		if con_status is "0" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 1
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to true
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to false
		else if con_status is "2" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 2
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
		else if con_status is "4" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 3
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
		else if con_status is "7" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 4
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
		else if con_status is "8" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 5
			set contents of text field "print_time" of tab view item "Setting" of tab view "tab" of window "main" to finalTime
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
			
		else if con_status is "10" then
			set content of control "pegel_con" of tab view item "Connection" of tab view "tab" of window "main" to 1
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to true
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to false
		end if
		--display dialog "here2"
		-- Anzeige empfangene Daten	
		tell application "Internet Connect"
			set bytes_received to bytes received of status as string
		end tell
		set received_print to bytes_received / 1024
		set received_mb to received_print / 1024
		set received_final to received_mb as integer
		
		set contents of text field "print_received" of tab view item "Setting" of tab view "tab" of window "main" to received_final
		
		
		-- Anzeige gesendetete Daten	
		tell application "Internet Connect"
			set bytes_sent to bytes sent of status as string
		end tell
		
		set sent_print to bytes_sent / 1024
		set sent_mb to sent_print / 1024
		set sent_final to sent_mb as integer
		
		set contents of text field "print_sent" of tab view item "Setting" of tab view "tab" of window "main" to sent_final
		
		
		return 1
		serialport close
	end if
end idle


on awake from nib
	(*	if notHidden then
		show window "startup"
		set notHidden to false
	end if *)
end awake from nib

on clicked theObject
	
	-- dieser block muss immer gleich sein mit dem obersten block
	set modem_check to serialport list
	if modem_check contains "/dev/cu.HUAWEIMobile-Modem" then
		set modem to "/dev/cu.HUAWEIMobile-Modem"
		set modem_display to "Web'n'walk Box compact"
		
		
	else if modem_check contains "/dev/cu.HUAWEIMobile-Diag" then
		set modem to "/dev/cu.HUAWEIMobile-Diag"
		set modem_display to "Kein gültiges Modem gefunden"
		return modem_display
		return modem
	end if
	--serialport close modem_check
	
	--	set idle of theObject to false
	--display dialog modem_display
	
	if name of theObject is "Connect" then
		tell window "main"
			set PopupButtonItem to modem_display
		end tell
		
		set theMatrixItem to title of current cell of matrix "theMatrix" of tab view item "Setting" of tab view "tab" of window "main"
		
		-- Check Huawei E220 gprsinternet
		if (PopupButtonItem is "Web'n'walk Box compact") and (theMatrixItem is "HSDPA Internet") then
			tell application "Internet Connect"
				set configName to "HUAWEI Mobile"
				set currentStatus to status of configuration configName
				--connect PPP configuration 1 to telephone number "gprsinternet"
				connect PPP configuration configName to telephone number "gprsinternet"
				quit
			end tell
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
		end if
		-- Check Huawei E220 business.gprsinternet
		if (PopupButtonItem is "Web'n'walk Box compact") and (theMatrixItem is "HSDPA Business") then
			tell application "Internet Connect"
				set configName to "HUAWEI Mobile"
				set currentStatus to status of configuration configName
				connect PPP configuration 1 to telephone number "business.gprsinternet"
				quit
			end tell
			set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
			set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
		end if
		
	end if
	
	if name of theObject is "Disconnect" then
		tell application "Internet Connect"
			if modem_display is "Web'n'walk Box compact" then
				set configName to "HUAWEI Mobile"
			end if
			set currentStatus to status of configuration configName
			disconnect configuration configName
		end tell
	end if
	delay 5
	set init_run to false
	idle
end clicked




Stefan,

Unfortunately, I can’t check much of anything regarding your script so all I can do is offer some suggestions to help you trace your problem.

One thing I noticed is in your Idle handler, in the if statement “if init_run then”, all of your code so far has to do with if init_run is false. Down at the bottom of the if statement you have a “return 1” before “serialport close” statement. I believe that when executing the code, when it hits the return, the program “returns” and any statements after the return go unexecuted. If you want the serialport closed, you need to place that before the return. I don’t know if that in itself is causing your problems or not. Where does the serialport information come from? I’m assuming that everything that references this serialport must be working but I cannot find this in any dictionary I have. Also, I’m not sure what the default return is for an Idle handler, but for the init_run true you may want to insert a value for the return or place a value outside of the if statement for the ammount of time you want the idle to wait before checking again.

That said, have you tried to display a dialog with the contents of your variables after the “tell app “Internet Connect”” blocks in the Idle handler to make sure they are what you expect?

Have you tried commenting out the try statements to make sure that the code inside is doing what it’s supposed to? In your if statements, are there other possible values that variables are being set to that are not taken into account?

Sorry that I can’t be a little more helpful here.

Below is a simple AS Studio script I wrote just to check some basic opperations. This may or may not help, but notice that the dialog “here man” never shows. The interface is just a window called “Main” with two buttons “Quit” and “Ok”. When run, the window shows and if no buttons clicked a dialog shows with the current value of t. If the button “Ok” is clicked, the window disappears and after a moment the dialog with the value of t shows and then the window appears again.

property t : true

on clicked theObject
	if name of theObject is "ok" then
		set t to false
		hide window "Main"
	else if name of theObject is "quit" then
		quit
	end if
end clicked

on launched theObject
	show window "Main"
end launched

on idle theObject
	--display dialog "idle"
	if t then
		display dialog "true"
	else
		display dialog "false"
	end if
	if visible of window "Main" is false then
		show window "Main"
	end if
	return 5
	display dialog "here man"
end idle

Good luck.

PreTech

Hi PreTech,

thanks for your response! I have played a little with the delay and found out, that having two new
lines of code will bring the best result:

delay 5

and

set code_state to status of connect

then I make 2 ifs and now its working much better…

Best Regards,

Stefan

:o Disclaimer: I know this is probably unrelated, but please just bare with me … I’m new to this :rolleyes:

I was researching AT-CSQ commands on a Mac using apple script and came across this forum (the only link in google!) Basically, I’m running a Sprint PC-5740 Data card on a G3 Lombard 400, running X 10.3.9 … although I can connect to the internet with this setup, I’m trying to find a way to display some sort of connection signal (dB). I’m in a non-EVDO area, so 1xRTT is the best I can do as far as a connection goes.

I know it’s suppose to be unsupported, discontinued, and all of that, but I can care less! I just want to know if it’s possible to show the signal strength of my connection while I’m online. I’m new to applescript, so any help in this would be greatly appreciated. Just a point in the right direction would be good.
Thanks

Model: G3 PB Lombard 400MHz/512MB Ram
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.3.9)