Search found 438 matches

by Tommie
Tue Jun 12, 2012 8:39 am
Forum: Software development
Topic: r910 introduces race condition into serial code
Replies: 11
Views: 3089

Re: r910 introduces race condition into serial code

And how does this the race condition? The same occurs with headRX as well: uint8_t SerialRead(uint8_t port) { uint8_t c = serialBufferRX[serialTailRX[port]][port]; if ((serialHeadRX[port] != serialTailRX[port])) { serialTailRX[port]++; if (serialTailRX[port] == RX_BUFFER_SIZE) { serialTailRX[port] =...
by Tommie
Tue Jun 12, 2012 8:34 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Adding new message types should not break anything, but neither should appending new data to existing ones; I refrained from adding another message type for performance reasons, since transmitting two additional bytes in this message is essentially free, while adding an additional message is not. It...
by Tommie
Tue Jun 12, 2012 1:08 am
Forum: Software development
Topic: r910 introduces race condition into serial code
Replies: 11
Views: 3089

r913 silently discard incoming incoming data

Since the UART receive interrupt is disabled while inside evaluateCommand(), any bytes received wile inside the function are silently discarded and not buffered. This is not a clean way to handle the situation; why not simply revert to the old style of incrementing headTX and tailTX, which is simple...
by Tommie
Mon Jun 11, 2012 11:44 pm
Forum: Software development
Topic: r910 introduces race condition into serial code
Replies: 11
Views: 3089

Re: r910 introduces race condition into serial code

you a trying to circumvent the inherent nature of an interrupt driven uart No, I am trying to circumvent the consequences of non-thread-safe programming. Which is easy if you change from one valid state to the next and ensure atomicity - which is not an issue if the state is represented by a single...
by Tommie
Mon Jun 11, 2012 11:09 pm
Forum: Software development
Topic: r910 introduces race condition into serial code
Replies: 11
Views: 3089

r910 introduces race condition into serial code

I think the last change introduces a race condition into the serial code. Consider this instruction sequence: void serialize8(uint8_t a) { headTX++; if (headTX == TX_BUFFER_SIZE) { headTX = 0; } bufTX[headTX] = a; checksum ^= a; #if !defined(PROMICRO) UCSR0B |= (1<<UDRIE0); #endif } For a brief mome...
by Tommie
Mon Jun 11, 2012 10:40 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

Yes, I know that processing is using the system wide java (which is the sane thing to do), but I find it amusing that they are shipping Java 6 while supposedly claiming that only Java 5 is supported.
by Tommie
Mon Jun 11, 2012 10:36 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

No, most linux distributions supply their own version of avr-gcc, just like Apple provides its own Java. People have already filed bugs against the Arduino project for sticking to such an old compiler which generates big code, and I don't quite understand why they are not upgrading. Saving 4kB witho...
by Tommie
Mon Jun 11, 2012 10:18 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Alexinparis wrote:Each message will get a response.
It should allow some mutualization in the request, for instance tailSerialReply(); and maybe the beginning of headSerialReply()

Can you explain further what you have in mind?
by Tommie
Mon Jun 11, 2012 10:13 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

This topic is about the GUI and some incompatibility with some version of java. There is one processing distribution that includes the required java environment. This one should be taken as the reference for those who want to play with the GUI compilation. One funny thing: Up until now, I did not k...
by Tommie
Mon Jun 11, 2012 10:07 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

I don't use avr-gcc, I use only Arduino IDE. Which in turn uses an included version of? avr-gcc. using a fresh r909 1) uncomment #define QUADX 2) uncomment #define FREEIMUv035_MS 3) uncomment #define GPS_PROMINI_SERIAL 57600 Binary sketch size: 31 050 bytes (of a 30 720 byte maximum) As I said, whe...
by Tommie
Mon Jun 11, 2012 9:46 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

I cannot reproduce your 170 byte; I only get a difference of 26648-26544=104 bytes, which is more than I thought. And consider the circumstances of this modification: I was hunting down every single byte to keep my copter from wreaking havoc on its own In this light, I have to admit that saving the ...
by Tommie
Mon Jun 11, 2012 8:54 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

Just to stop this nonsense, I just commited a fix with my own method of copying an array.
by Tommie
Mon Jun 11, 2012 8:05 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

so for me .. i think its better to renounce of some features if thay would make it less simple. there are other flight control FW's that have all that stuff done.. but i never saw any one being so happy with it as many are with MWC. And how many of these happy people are actually touching the code ...
by Tommie
Mon Jun 11, 2012 7:56 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

It was not my intention to break anything; to be honest, I wasn't aware of this method being an Java 6 addition, but even if I had been I would have probably used it, for Java 6 is by no means bleeding edge technology. I find it awkward that instead of using ones coding skills to mitigate this issue...
by Tommie
Mon Jun 11, 2012 7:08 pm
Forum: Software development
Topic: Tiny-GPS integrated into Multiwii (GPS/Sonar/Optical to I²C)
Replies: 195
Views: 70891

Re: Tiny-GPS integrated into Multiwii (GPS/Sonar/Optical to

OK, I just added the capability to send an init string to the GPS unit and switch the baud rate afterward:
https://github.com/wertarbyte/tiny-gps/
Since I do not have an appropiate GPS unit at hand, please test this new version; bug reports are welcome :-)
by Tommie
Mon Jun 11, 2012 6:12 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

it is really very simple, is it not? An unneccessary incompatibility was introduced and detected. So now it is time to rewrite in compatibility mode. As I do not know a proper translation, I'll stick to the language we both understand: "Der Ton macht die Musik." This (sub)thread was not s...
by Tommie
Mon Jun 11, 2012 4:02 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Actually, flash usage has gone down. I just compiled a firmware image from the code before introducing get_flag/set_flag: #before stefan@exa:~/git/multiwii-firmware [old_test] $ avr-size build/MultiWii.hex text data bss dec hex filename 0 27060 0 27060 69b4 build/MultiWii.hex #current stefan@exa:~/g...
by Tommie
Mon Jun 11, 2012 3:45 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

OK, I fixed the errors in LCD.ino, so I can compile the configuration using the Arduino IDE; just a second... //EDIT The LCD was not enabled in your config, I accidently tried compiling an old configuration I had still lying round. Fixed the errors regardless Your configuration yields a file of <27k...
by Tommie
Mon Jun 11, 2012 3:28 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

- I checked the last flag, and the performance impact is much better. From this point it’s ok. But it consumes around 200 bytes of flash mem. (just realize you exchange just 16 RAM bytes against 200 bytes flash mem, the business is not very fair) I cannot confirm this. Using the macros, the compile...
by Tommie
Mon Jun 11, 2012 3:03 pm
Forum: Software development
Topic: TWI (Two Wire Lib) Question
Replies: 4
Views: 1738

Re: TWI (Two Wire Lib) Question

Probably not. The Wire library does its own initialization, so the two systems would probably disturb each other.

What exactly do you need the Wire library for? For most purposes, equivalent convenience functions are available in to Multiwii code.
by Tommie
Mon Jun 11, 2012 1:26 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

Hamburger wrote:
Tommie wrote:Just upgrade your >6 years old version of Java.

You are not funny and clueless.
Latest java upgrade is 10 months old, nothing newer available from the vendor. But why should you care.

Don't get rude. Java 6 has been available since 2006. What kind of funny and/or clueless vendor is this?
by Tommie
Mon Jun 11, 2012 1:19 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

OK, I did some modifications to the GUI as well as the firmware. It's looking good, and Kos already tested the changes last night. What has been done to the GUI: - serial communication is handled in a separate thread, so drawing the GUI and exchanging messages with the copter do not block or limit e...
by Tommie
Mon Jun 11, 2012 1:12 pm
Forum: Software development
Topic: TWI (Two Wire Lib) Question
Replies: 4
Views: 1738

Re: TWI (Two Wire Lib) Question

In this piece of code you wait for the TWINT flag to set and receive the ACK. But what value makes it stop the counter to tell that the ACK has been received. The TWINT flag will be set but how does he actually do it? And what happens when you put the TWCR on 0.. It resets the TWINT register as in ...
by Tommie
Mon Jun 11, 2012 1:01 pm
Forum: Software development
Topic: MultiWiiConf_shared is broken - function copyOf(byte[], int)
Replies: 56
Views: 12252

Re: MultiWiiConf_shared is broken - function copyOf(byte[],

Just upgrade your >6 years old version of Java.
by Tommie
Sun Jun 10, 2012 7:40 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

And again, flash memory is a precious resource. It's hard to evaluate the differences in flight for a small delay like this. A lot of things are empirical ans generally speaking, a smaller loop offers better performances. A WMK+NK combination offers a 6ms delay, and the difference is very noticeabl...
by Tommie
Sun Jun 10, 2012 5:07 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Here are the changes applied to config.h: error: 'PB4' was not declared in this scope. error: 'PC0' was not declared in this scope. The code must compile with arduino IDE , not only with your gcc environment. To evaluate this, let's for the moment put 4 instead of PB4 and 0 instead of PC0. Weird, p...
by Tommie
Sun Jun 10, 2012 2:21 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

irrelevant hogwash. Sure. Other mistakes are irrelevant. But firmware and GUI not being in sync for 2 hours due to my patches is a major international incident. Quick, get the red phone! I am not willing to delve deeper into this; in my opinion, your postings have left the ground of technical discu...
by Tommie
Sun Jun 10, 2012 1:53 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

I ask for a valid configuration with the current code. Not a specific code which we are not aware of. I am using the current HEAD of MultiWii_Shared. Yes, I also tried disabling my own specific modifications. Here are the changes applied to config.h: #define QUADX #define I2C_SPEED 400000L #define ...
by Tommie
Sun Jun 10, 2012 11:17 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

that would not explain that in the long run (1 or 2 minutes), there is no errors at all Sure it does. The receive buffer has to bridge the time between two calls to serialCom. The send buffer has too be big enough to hold all the reply data that has been generated by the messages processed until th...
by Tommie
Sun Jun 10, 2012 11:14 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

I repeat the question: Based on the last rev with the Arduino IDE compiler only, please indicate the options to check and where to put the checking sequence to obtain this result ? As Arduino uses avr-gcc, there is no difference. I cannot provide you my config for the moment, but unless you know of...
by Tommie
Sun Jun 10, 2012 10:43 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Alexinparis wrote:once again in the last rev, the GUI is very laggy (3 or 4 update per second)

Can't reproduce. I tried it this night, it was quite responsive.
by Tommie
Sun Jun 10, 2012 10:37 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Now serial is broken again.The ATMega firmware cannot keep up with the number and speed of request that arrive at once; so the TX buffer fills and overwrites itself. This is why the checksums fail. So how do you explain with a 256 buffer, there is no more error of checksum ? (I did the test with th...
by Tommie
Sun Jun 10, 2012 7:27 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

3) then uncheck SERIAL_GPS based on r885: code size impossible: 31420 based on 0606: code size: 30550 Due to renaming, I cannot produce a proper.diff to locate the key differences; but why is a file size of 31420 byte impossible? With 32kB of flash memory, that should be flashable. And before you r...
by Tommie
Sun Jun 10, 2012 1:47 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Alexinparis wrote:Serialize32 and serialize16 are no more equivalent in the current code

Of course not, they never were. One serializes uin32_t, the other uint16_t, and both can be reduced to variants of serialize8.
by Tommie
Sun Jun 10, 2012 1:40 am
Forum: Software development
Topic: [Patch] Replacing boolean flag variables with bit field
Replies: 11
Views: 2888

Re: [Patch] Replacing boolean flag variables with bit field

In the mainloop, the stack has already collapsed again. You'd need probes throughout the program (see my latest patch), but if you encounter the situation, it's probably already to late. That's the problem with Turing machines: You cannot decide whether they fill your memory or terminate. Greetings ...
by Tommie
Sun Jun 10, 2012 1:30 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

So just a plain serial interface, just like the rest of us uses (via USB, via Bluetooth, or even to the COM port).
The problem is that the GUI is sending far more requests than the copter can handle; that's why we are reducing the request frequency, to give the copter some time to transmit the answer.
by Tommie
Sun Jun 10, 2012 1:20 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

via USB? So you are using an ATMega32U4?
by Tommie
Sun Jun 10, 2012 1:13 am
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

OK, back to the topic at hand. I added a second thread that handles the serial transmission, leaving the UI thread alone. It also introduces a request interval so the copter does not get flooded with requests; for the moment, I limited the transmission rate to one request each 20ms; At 115200bps, tr...
by Tommie
Sat Jun 09, 2012 11:46 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

This simple function launched at different place shows we are far from seeing a ram memory run out That there is at least 400 bytes free in all cases I tested with 256 octets serial buffer for TX and RX. With both buffers at 256 byte, I am down to 185 bytes, but I only placed the test function in t...
by Tommie
Sat Jun 09, 2012 11:37 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

kos wrote:ok, you can test with the latest ?

I just did :-(
by Tommie
Sat Jun 09, 2012 11:36 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Now serial is broken again.The ATMega firmware cannot keep up with the number and speed of request that arrive at once; so the TX buffer fills and overwrites itself. This is why the checksums fail. invalid checksum for command 101: 21 expected, got 1 invalid checksum for command 36: 81 expected, got...
by Tommie
Sat Jun 09, 2012 7:36 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

Flash size is precious, probably more than ram size. Serial consumes a lot of ram memory, but “256 is choosen to avoid modulo operations on 8 bits pointers” was introduced for a good reason. => at least 0.5k burned in the recent changes. And reducing operations made inside an ISR is critical. Seria...
by Tommie
Sat Jun 09, 2012 7:01 pm
Forum: Software development
Topic: [Patch] Replacing boolean flag variables with bit field
Replies: 11
Views: 2888

Re: [Patch] Replacing boolean flag variables with bit field

What about implementing a safeguard for the stack/heap limit ? We are walking on a thin line, so it would be better to know how much memory do we left.... How would you implement this? If I call a method with a local variable "uint8_t buf[TOO_LARGE_FOR_MY_STACK]", how will you detect if t...
by Tommie
Sat Jun 09, 2012 6:43 pm
Forum: Software development
Topic: [Patch] Replacing boolean flag variables with bit field
Replies: 11
Views: 2888

Re: [Patch] Replacing boolean flag variables with bit field

Don't know, but acceptable. If you exceed flash size, you notive while flashing. If your stack crashes into your heap, you only notice when your ISRs are trashed and the copter takes off to location unknown. Luckily, I was able to grab it before it could deal some real damage. Therefore, SRAM is far...
by Tommie
Sat Jun 09, 2012 4:57 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

like Alex suggested : lets extends the new msp to the pid settings , once this is done we should be ok . Done: m And the GUI has been updated as well, although it does not generate GUI elements from this message yet: m Ok ! I will extends the gui I already have a prototype running, but it's a litle...
by Tommie
Sat Jun 09, 2012 4:29 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

kos wrote:like Alex suggested : lets extends the new msp to the pid settings , once this is done we should be ok .

Done:
https://code.google.com/p/multiwii/source/detail?r=882
And the GUI has been updated as well, although it does not generate GUI elements from this message yet:
https://code.google.com/p/multiwii/source/detail?r=883
by Tommie
Sat Jun 09, 2012 4:03 pm
Forum: Software development
Topic: New Multiwii Serial Protocol
Replies: 409
Views: 227240

Re: New Multiwii Serial Protocol

You may not know this, but _shared is meant as a common basis for working code as in work in progress . It is not your personal playgorund. It is not ok to leave your basic coding errors for others to stumble upon. Right, because code from _shared has always been completely reliable and never ever ...
by Tommie
Sat Jun 09, 2012 2:15 pm
Forum: Software development
Topic: [Patch] Replacing boolean flag variables with bit field
Replies: 11
Views: 2888

Re: [Patch] Replacing boolean flag variables with bit field

i dont really know how flags work .. but that sounds good. maybe you can explain why this uses less RAM & ROM and how it works? It preserves RAM because having a uint8_t in memory will require a complete byte, even if you are only using one bit of it (like a boolean flag, 1/0). By using a bitma...
by Tommie
Sat Jun 09, 2012 11:39 am
Forum: Software development
Topic: [Patch] Replacing boolean flag variables with bit field
Replies: 11
Views: 2888

Re: [Patch] Replacing boolean flag variables with bit field

I made a few additional patches to reduce the memory (both RAM and ROM) footprint:

Omit servo variables unless needed: https://github.com/wertarbyte/multiwii- ... 5b4bfaaaeb
Shrink rcalue array for standard receivers: https://github.com/wertarbyte/multiwii- ... 7dc0c8b08d
make Buzzer optional: https://github.com/wertarbyte/multiwii- ... 2b77fb0309

Feel free to discuss :-)