help translate this qbasic code to pocketC

Discuss PocketC for CE (including Desktop Edition)

Postby otakribut1 on Sun Apr 17, 2005 11:41 pm

i'm trying to getpocketC to transmit serial data through LEGO ir TOWER --then--this ir data is received by the LEGO RCX.
this code is by Bert Van Dam.

SUB LegoOpenCom

'This is the addres of Com 2, change this if you're using another port.
'com1=&H3F8 com2=&H2F8 com3=&H3E8 com4=&H2E8 com5=&H2F0 com6=&H3E0 com7=&H2E0 com8=&H260
'lpt1=&H378 lpt2=&H278 lpt3=&H3BC
Register = &H3F8

'Open the comport for random, disable all checks (otherwise some sort
'of handshaking protocol will start, and there's noting to shake hands
'with). Note the size of the buffers, you need lots of buffers to keep up.
OPEN "COM1:2400,N,8,1,CD0,CS0,DS0,OP0,RS,TB8192,RB8192" FOR RANDOM AS #1

'What we really want is Odd (but this can't be done in Basic) so
'change the Line Control Register accordingly (offset 3 to COM address)
OUT (Register + 3), &HB

'For the Cybermaster DTR line must be high (default) and RTS line must
'be low. So force RTS and DTR in the Modem Control Register (offset 4 to
'the COM address).
Temp = INP(Register + 4)
Temp = Temp OR 1 'DTR on
Temp = Temp AND NOT 2 'RTS off
OUT (Register + 4), Temp


ToSend$="55 ff 00 51 ae 03 fc 54 ab"
'CALL SendString(ToSend$)
PRINT #1, ToSend$;
Posts: 12
Joined: Tue Feb 22, 2005 2:26 am

Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 3 guests