Really Unexpected Task Behavior

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Really Unexpected Task Behavior

Post by afanofosc »

Everything I write in Delphi I try to write so that it can be compiled with Free Pascal and Lazarus. It is not 100% compatible with Lazarus at this point but my NeXTTools/NXTCC utility for Mac OS X and Linux are both built using Lazarus and Free Pascal on Mac and Linux platforms using exactly the same sourceforge code that I compile using Delphi. I would love to have some help from people like yourself and others here who might be interested in working with me to enhance the BricxCC IDE to support code folding, terminal window output, breakpoints, better variable watching, etc...

You can buy the Delphi XE2 Starter edition online from Embarcadero.com for $149, btw. The current codebase works with Delphi 7 but with a little work I think I can get it to compile with XE2.

So, you are saying that if you use SendRemoteString that you get data on the PC but not if you use BluetoothWrite?

Here's the code for SendRemoteString and BluetoothWrite:

Code: Select all

#define __sendRemoteString(_conn, _queue, _str, _result) \
  acquire __RemoteMutex \
  mov __SRSTmpBuf, __DCMessageWritePacket \
  replace __SRSTmpBuf, __SRSTmpBuf, 2, _queue \
  arrsize __SRSTmpLongVal, _str \
  replace __SRSTmpBuf, __SRSTmpBuf, 3, __SRSTmpLongVal \
  arrbuild __SRSSendBuf, __SRSTmpBuf, _str \
  __connectionSCDCWrite(_conn, __SRSSendBuf, _result) \
  release __RemoteMutex

#define __connectionSCDCWrite(_conn, _buffer, _result) \
  brcmp LT, __ConnWrite_Else##__I__, _conn, 4 \
  __RS485WriteSCDC(_conn, _buffer, _result) \
  jmp __ConnWrite_EndIf##__I__ \
  __ConnWrite_Else##__I__: \
  __bluetoothWrite(_conn, _buffer, _result) \
  __ConnWrite_EndIf##__I__: \
  __IncI__

#define __bluetoothWrite(_conn, _buffer, _result) \
  acquire __CBTWMutex \
  mov __CBTWArgs.Connection, _conn \
  mov __CBTWArgs.Buffer, _buffer \
  syscall CommBTWrite, __CBTWArgs \
  mov _result, __CBTWArgs.Result \
  release __CBTWMutex
As you can see from the above code, SendRemoteString calls __bluetoothWrite with a buffer that contains a valid MessageWrite direct command. So it is really not possible for the problem to be on the NXT side - at least not at the API level. Perhaps in your code, which I have not yet seen.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
spiked33
Posts: 14
Joined: 16 Feb 2012, 17:20

Re: Really Unexpected Task Behavior

Post by spiked33 »

Ok, I am downloading XE2 - i will have a look. The thing is, SharpDevelop has an editor already written, by several people over many years, and is on par with visual studio - I don't think you and I can accomplish the same. I would love to talk you into the dark side, but I realize you need/want to support cross platform, that is never an issue for me. I will consider help after I look at XE2 some, thanks for the pointer, I had never heard of a delphi replacement/sequel. I did use/look at delphi back in the days, and started out with turbo Pascal until Turbo C became available. I'm at a point where most language are 'just another syntax' to me, except Prolog :)

Yes, same PC code - sendResponseString is received OK, bluetoothWrite never sends a byte. I'll double check on that later today, but I'm pretty sure. I''l put it all together and zip it to you if you want, I assume you at least have the free visual studio 2010?

I'm still really hunting for a debugging solution. I put together an IDE using a barely documented thirdParty editor, in a day. It was because I had available a really nice debugger. On the other hand, I've spent weeks on simple NXT code to follow a line (well a little more complicated than that, but similar). A debugger makes all the difference in the world. So; http://www.sorosy.com/lego/nxtdbg/ looks quite inactive. Is that because it is stable and useful? (if you know) Not having looked at it, would the techniques it use be available currently with the enhance firmware? (if you know) I know in my IDE, if the above answers were yes, similar functionality could be added in fairly quickly. Not sure on yours. I will also look at this (sorosy) more this afternoon.

BTW if you want to discuss directly spiked3 at gmail dot com

Mike
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Really Unexpected Task Behavior

Post by afanofosc »

A lot of people are unaware of what you can do with BricxCC for NXC debugging. It still needs a lot of work but you can do a lot.

http://dl.dropbox.com/u/53437658/debug.m4v




John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Really Unexpected Task Behavior

Post by afanofosc »

What I would like to see is your NXC code which you have yet to post.

I program in Visual Studio 2010 at work every day using C# and C++. My primary programming environment at work, though, is Delphi 2010 and XE2.

Adding support for breakpoints and single stepping when the code is executing remotely is not as easy as you might think. The debugger written by Tamas Sorosy is only for NBC (assembler) and it is no longer in-sync with the current compiler version. It might still work.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
spiked33
Posts: 14
Joined: 16 Feb 2012, 17:20

Re: Really Unexpected Task Behavior

Post by spiked33 »

I was posting my code just now, having completed testing. I will start a new thread specific to bluetooth and we can drop the IDE talk. My bricxCC does not have any of that debugging stuff. But I dropped back a version because the latest did not match up line numbers with errors and the old one did. please see new post.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Really Unexpected Task Behavior

Post by afanofosc »

You may want to update to the latest test release of the compiler and IDE if you want to rule out that your problems are caused by ancient compiler bugs that no longer exist.

The current build of the compiler/IDE does not have a line number error message problem - at least not that I am aware of.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests