Handheld Basic for Windows CE and Palm OS smartphones

HB++ community

IrCOMM

Index | Exchange manager
Reply to this topic | Print this topic | New topic | Search << >>
Page 1 of 1

Message
petiska


Joined: 15 Oct 2003
Posts: 7

PostPosted: Wed Oct 22, 2003 5:19 pm 

IrCOMM

Reply with quote

here is my code:
Private Sub cmdWrite_Click()
Dim ir as new StreamSerial
ir.Open hbPortIrComm,115200
ir.Direction=hbStreamWrite
Write ir, "test"
ir.Close
End Sub

Private Sub cmdRead_Click()
Dim ir as new StreamSerial
ir.Open hbPortIrComm,115200
ir.Direction=hbStreamRead
Read ir, lblText
ir.Close
End Sub

when I try terminals like Online or ec (in IrCOMM mode), they always trying to discover nearby device for few seconds (using IR viewer I see blinking of IR LED) - see details of IrCOMM protocol on www.irda.org.
thank you
petiska

View user's profile Send private message

jpa
Learner

Joined: 30 Jul 2003
Posts: 3954
Location: Peter Holmes Center - Earth

PostPosted: Wed Oct 22, 2003 10:50 pm 

Reply with quote

Hi petiska,

You don't have to specify Direction as you use the hbPortIrComm parameter. hbPortIrComm is bidirectional.

Just a question : what is the lblText variable in your sample ? Is it a Label object ?
If yes, this can't be done. You must use a fixed Type like Byte, String, Double,Date....

see also : Home > Language Reference > Classes > StreamSerial Class in the help file.

Best regards

The HB++ team

View user's profile Send private message Send e-mail

petiska


Joined: 15 Oct 2003
Posts: 7

PostPosted: Fri Oct 24, 2003 9:41 pm 

Read routine..

Reply with quote

jpa!
thanks a lot for good advices. Now my routines work better, but I have still some issues. Following routines (both Write,Read) work great for communication between 2 PDAs running same code (one is PALM V, one is Sony Clie SJ22). The problem is when one PDA runs standard terminal (like Online, ec) and these HB++ routines. Write routine works OK (write from HB++ routine to IR port and read in standard terminal), but Read routine doesn't work (write from terminal - read on HB++ side). I tried both PDAs and neither works. Number od bits, speed, parity is set correctly, I tried differrent settings of handshake on terminal side, HB++ setting doesn't offer that (SW, HW, none). Any ideas?
thank you

Private Sub cmdWrite_Click()
Write ir, "test"
End Sub

Private Sub cmdRead_Click()
dim mystr as String
Read ir, mystr
field1.Text=field1.text&mystr
End Sub

Private Sub Form_Load()
ir.Open hbPortIrComm,115200
End Sub

View user's profile Send private message

jpa
Learner

Joined: 30 Jul 2003
Posts: 3954
Location: Peter Holmes Center - Earth

PostPosted: Fri Oct 24, 2003 11:58 pm 

Reply with quote

Hi petiska,

Hmmm...sounds very strange...can you send us your project at the following address, as your terminal settings to :
support@handheld-basic.com

Best regards.

The HB++ team

View user's profile Send private message Send e-mail

jpa
Learner

Joined: 30 Jul 2003
Posts: 3954
Location: Peter Holmes Center - Earth

PostPosted: Sat Oct 25, 2003 3:22 am 

Reply with quote

hi petiska,

Nice app idea ! Well, you just need to use the StreamSerial Ready property (see 'Home > Language Reference > Classes > StreamSerial >Ready Property' in the help file) to manage your read procedure.This property is typically used together with a timer to carry out polling on a port.

So your Terminal apps can be something like this :

First declare your StreamSerial object and a timer

'Declarations section
public ir as new StreamSerial
public t as new Timer


Then create a button object, named it cmdConnect, and paste the following code in the form editor :
Private Sub cmdConnect_Click()
  'open the ir port, set parameters
  ir.Open hbPortIrComm,9600
  ir.BitsPerChar=8
  ir.Parity=hbParityNone
  ir.StopBits=1
 
  'init a timer to read ir data
  t.Interval=100
  t.Enabled=True
End Sub


Of course, theses settings can be changed. See the relevants help pages. You can also write an error handler.

Then, paste the following code for your cmdWrite button :

Private Sub cmdWrite_Click()
  'Write a sample string
  Write ir, cstr(now) & " : My string "
  'Flush the write buffer
  ir.Flush hbStreamWrite
End Sub


Here we write a sample string....

Then paste the following code to handle reading from your StreamSerial object :
Private Sub t_Timer()
  Dim b as Byte
  'if there is somes bytes waiting in the internal buffers
  While ir.Ready(hbStreamRead)>0
   'read byte per byte
   Read ir, b
   'Display it
   Field1.Text=field1.Text & chr(b)
  Wend
End Sub


Do not forget to close the ir port !

Private Sub cmdClose_Click()
  'close the connection
  ir.Close
End Sub


I've tried this code with the Online terminal and it works well Cool

Hope this helps.

Regards
The HB++ team

View user's profile Send private message Send e-mail

petiska


Joined: 15 Oct 2003
Posts: 7

PostPosted: Sat Oct 25, 2003 10:26 pm 

IrCOMM terminal application

Reply with quote

jpa!
Everything works pretty! Thank you, thank you, thank you. When it comes to develop SW, HW guy like me always looks to find easy solution, quick and simple. I tried NSBASIC,MOBILE VB, and others. These are pieces of crap. Your product is 100x better. I live in USA (Silicon Valley) and I have to say, I never seen such a excellent support as your company provide. Specially here in States it's rare. Another nice European company!
I plan to use IR communication in many projects. Our company makes detection and position sensors. IR feature of PDAs makes these devices very useful in automated manufacturing to find measurements, set/get control parameters and status of equipment. Greatly reduces cost, eliminating separate displays, keyboars,..
Your product and support is more than great! petr perner Cool

View user's profile Send private message

thorngrend
Master

Joined: 16 Oct 2003
Posts: 249
Location: Illinois

PostPosted: Wed Feb 23, 2005 7:52 pm 

IrCOMM

Reply with quote

I have a project for a device (not a palm) that will transmit data IR. They want me to collect this data into a table on the palm. The specs tell me this:

The data stream will look like this

Position 0 1 2 3 4 5 6 7 8
Record 1 J x x x x x x I D
Record 2 A x x x x x x x x
.
.
Record N T x x x x x x x x

Where:
x is any byte value

ID is a unique device identifier, as a short integer.
‘J’ is first byte of first record
‘T’ is first byte of last record, records 2 through N will not have a ‘J’ or a ‘T’ in position 1. N could be as small as 2, as large as 6200.


I have not done any project using IR myself. I have been playing around with the sample code JPA posted in this thread. If I use the timer as in this sample code JPA posted it uses a timer. WIll this work to capture records that flow in as I described here? Any ideas on making sure I read this data stream correctly?

Thanks
_________________
Dan

View user's profile Send private message Send e-mail Visit poster's website

jpa
Learner

Joined: 30 Jul 2003
Posts: 3954
Location: Peter Holmes Center - Earth

PostPosted: Thu Feb 24, 2005 4:48 pm 

Reply with quote

Hi Dan,

Yes, you can use the 'timer technique' to pool the Ir buffer. However, it will be handy if you can identify the start of the records transmission.

Palm to device: Give me your data!
Device to palm: Ok (a magic number)
J x x x x x x I D
A x x x x x x x x
....
....
N T x x x x x x x x

You store the incomming data in one streamMemory as 6200*9 bytes=55800 bytes, it's <64kb.

You can also create the records on the fly as long you get enough data.

Regards,

The HB++ team

View user's profile Send private message Send e-mail

thorngrend
Master

Joined: 16 Oct 2003
Posts: 249
Location: Illinois

PostPosted: Fri Feb 25, 2005 5:48 pm 

Reply with quote

Thanks JPA Exclamation

As always thank you for your input, nice idea on starting the transmission. I am going to spend some time working with this now.

Thank you much Exclamation Very Happy
_________________
Dan

View user's profile Send private message Send e-mail Visit poster's website

thorngrend
Master

Joined: 16 Oct 2003
Posts: 249
Location: Illinois

PostPosted: Fri Feb 25, 2005 9:03 pm 

Reply with quote

Another question on this. The data coming from the device, the 9 byte records. Using a procedure similar to this one, except I will be writing each byte into a field.


Private Sub t_Timer()
  Dim b as Byte
  'if there is somes bytes waiting in the internal buffers
  While ir.Ready(hbStreamRead)>0
   'read byte per byte
   Read ir, b
   'Display it
   Field1.Text=field1.Text & chr(b)
  Wend
End Sub


The data will be in binary format that I will be writing to the record. Are there any issues with that I should be aware of?

Since the letter J will be in position 1 of the first record and T will be in position 1 of the last record. I assume I can read the first byte, then if not a T then count each byte until I reach 9 and then start a new record. Writing each byte into a double data type. Does that sound reasonable?
_________________
Dan

View user's profile Send private message Send e-mail Visit poster's website

HawkWolf


Joined: 07 Apr 2005
Posts: 2

PostPosted: Sun Apr 10, 2005 7:17 pm 

Reply with quote

Hi again JPA! Thanks again for such a useful program! My second post here is about IRComm. At college we use a lot calculators as support for our studies. So the eternal fight is always HP VS TI. Until Robert Hildinger, introduced the first HP 48 emulator for Palm, another competition! For free! Great emulator, has saved me lots of trouble. But there's a little problem with it, it doesn't supports the transfer through the IR port. So I'm trying to improve some sort of application (like the terminal that I saw here), to send and recieve data from a HP 48 GX (or another reference). But I'm stucked, because of the 'Kermit' protocole. Do you have any idea about this protocole? I wish you could give some sort of start.

Thanks,
_________________
HawkWolf, best to know yourself, that hear lousy critics.

View user's profile Send private message

adel


Joined: 28 Mar 2006
Posts: 5
Location: Bordeaux - france

PostPosted: Fri Apr 14, 2006 10:52 am 

Reply with quote

Hi JPA

I try this code on my Palm V and i've got a little problem.

The goal of my application is to read Logical Input (or writing output) on an external card via the Com port of the Palm.

I'm testing the communication with Hyper terminal on a PC (first)

everything works good (reading and writing) but when I stop the application (ir.close), an error appears:
Error 24:Not Connected

if i press done in the message box error , it appears again and again ...

And it's impossible to stop the plam .-> soft reset


help

Adel

View user's profile Send private message

adel


Joined: 28 Mar 2006
Posts: 5
Location: Bordeaux - france

PostPosted: Fri Apr 14, 2006 5:34 pm 

Reply with quote

I ve found the solution

just desable the timer befor desable the comm

thank you...

View user's profile Send private message

Display posts from previous:   
Page 1 of 1
Index | Exchange manager
Reply to this topic

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum