New topic: 

detect serial connection

<http://forums.realsoftware.com/viewtopic.php?t=32177>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       arnoldino           Post subject: detect serial connectionPosted: 
Mon Jan 25, 2010 5:38 am                        
Joined: Tue Oct 31, 2006 2:57 am
Posts: 65              hello

i would like to detect somehow the serial connection, after the port is opened.

i mean i want to be able to figure it out, when the cable is unpugged.

my first thought was to send a check message, and look for the answer. the 
problem is, i will not get any answer to fire up the dataavailable method, if 
the cable is unplugged.

the second thought was using a timer.
but the following code doesn't work for me

Code:
app.objUtils.writeSerial(app.Commands.cmdKeyOK)
Serial1.XmitWait
if Serial1.BytesAvailable<1 then
  app.SleepCurrentThread(5)
else
  dim mm as MemoryBlock=Serial1.ReadAll
  
  if mm.Size>0 then
  if mm.Byte(1)=&hFF then
  MsgBox "ok"
  else
  MsgBox "nem ok"
  end if
  end if
end if


i have other code in the DA event, and it is fired, but why this code doesn't?

this code is a try, after this i would like to go for the next conception:

Code:
serial1.write(checkConnection)

app.slepcurrentthread(20)
dim m as memoryblock=serial1.readall
if m.size<1 then
  msgbox "cable is disconnected"
end if

   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to