I experience a strange problem in one of my programs. In this program I use an US sensor on port 1. Under normal circumstances this program works fine. However, the program also has the option to output data to the NXJChartingLogger. If I use this option in the code the US sensor just returns 255 (out of range). I tried to reproduce this in a smaller program but then everything keeps working fine, with or without the chartingLogger enabled. Therefore I suspected it could have something to do with program size. With the chartingLogger disabled the program size is 55104 bytes, with the logger enabled this is 64304 bytes. The change in program size is because I disable the option by commenting out some lines of code. Could the strange behavior have something to do with the program exceeding the 64K boundary? Is there an official maximum to program size?
I also tried to put the US sensor on a different port. It then keeps working no matter the logging enabled. So I placed another sensor on port 1 and this halted when I used the logging option. The strange thing is that I was able to see that this sensor worked for a brief moment. Only when the code below was executed it stopped working. It doesn't matter if I really make a connection or let the connection time out. I therefore conclude that the ChartingLogger itself isn't to be suspected but the Bluetooth class might be involved in this problem. Indeed, when I replace the Bluetooth connection for a USB connection the program starts working fine again.
- Code: Select all
LCD.drawString("Connect over BT", 0, 0);
NXTDataLogger log=null;
NXTConnection connection = Bluetooth.waitForConnection(20000, NXTConnection.PACKET);
if (connection != null) {
try {
log= new NXTDataLogger();
log.startRealtimeLog(connection);
}
catch (IOException e) {
log=null;
}
}
So. To wrap thing up. Port 1 stops working when I have a large program in combination with a Bluetooth object.
