« first day (3625 days earlier)      last day (1308 days later) » 

3:25 AM
I added code for GPS on rPi and tidied code a bit, now I can no longer receive data from arduino. wtf
 
3:56 AM
We are mostly dead wood. I find this very recognizable for myself. I also think this applies a lot to programmers. We like pretend to know what we're talking about.
But we're just making things up as we go.
 
 
3 hours later…
6:43 AM
i R dumb, instead of this:
if ((arduino_port = serialOpen ("/dev/ttyUSB1", 9600)) < 0)
I wrote this:
if (arduino_port = serialOpen ("/dev/ttyUSB1", 9600) < 0)
 
 
6 hours later…
12:18 PM
but yeah it's not new per se, compilers have been doing some version of it on the highest optimization level for ages. The issue was that technically in C++ that might have been a violation of as-if because the dynamic allocation could have failed but the static allocation might not. That change allows that to still be valid if I'm reading it correctly.
 
nwp
@TelKitty if (arduino_port = serialOpen("/dev/ttyUSB1", 9600); arduino_port < 0)
 
 
2 hours later…
user7659542
2:39 PM
@nwp Good way of coding: Good for guaranteeing job security.
 
nwp
If that keeps out certain developers it's probably better that they are kept out. Looking up the syntax of if should be doable for any developer.
 
user7659542
yhea but I actually didn t know you could write it that way, ie everything like this inside the if statement
 
user7659542
I typically go for
 
user7659542
if (myFunction () < 0)
{
    log_error(...);
}
 
user7659542
or simply:
 
user7659542
2:42 PM
iArduinoPort = myFunction();
if (iArduinoPort <0)
...
 
nwp
I wouldn't fault anyone for not knowing the syntax, but I'd expect them to look it up when coming in contact with it instead of giving up.
 
user7659542
@nwp would you write it like that if at your lace of work or in production code?
 
nwp
Yes. The return value is necessary to get so you can't use the first version and the second version leaves a useless variable in scope. There is a reason why they added this syntax. It produces somewhat cleaner code. Rejecting it because it's new-ish doesn't seem correct to me.
 
user7659542
with your example, if I understood your point properly, you also have arduino_port in scope
 
user7659542
otherwise you would not be able to use it a couple of lines further
 
nwp
2:45 PM
Inside the if where it has a valid value yes, outside of it where it doesn't no.
 
user7659542
hmm, no? Because you have done this
 
user7659542
int arduino_port;
if (arduino_port = serialOpen("/dev/ttyUSB1", 9600); arduino_port < 0)
    //some code
 
user7659542
open will return a file descriptor
 
user7659542
you ll have to use it later
 
nwp
Well, don't do that. Use if (int arduino_port = serialOpen("/dev/ttyUSB1", 9600); arduino_port < 0).
 
user7659542
2:46 PM
@nwp except you cannot do this then:
 
nwp
Probably with a > assuming valid ports are positive.
 
user7659542
if (int arduino_port = serialOpen("/dev/ttyUSB1", 9600); arduino_port < 0)
    //error handling

write(arduino_port, "abc", strnlen("abc",4));
 
user7659542
you need to have the variable beyond the scope of your if statement
 
nwp
Well yeah, if that is the error case there is no point in catching the variable. You put the not error case into the if.
If you return after a failed serialOpen you don't actually need the fancy syntax since you immediately destruct the invalid handle with a return anyways.
 
3:00 PM
@traducerad actually you can, the variable is in scope for the if and any chained else blocks
it's de-facto equivalent to surrounding the entire if statement in a block
 
user7659542
3:41 PM
The point I am trying to make is that you are trying to open the device in order to be able to read/write to it. In order to read/write to is you need the variable arduino_port
 
user7659542
In order to use that variable it has to be accessible beyond the scope of the if statement
 
4:02 PM
@traducerad depends on what you're doing?
 
 
2 hours later…
 
3 hours later…
8:28 PM
So, I have an interview via zoom where I need to share my screen for a few hours and they will watch me code
interesting world
also part of my interview at another place is to give a technical talk on my previous work
new features of the interview process
 
8:51 PM
@traducerad Yeah, I mean don't do that. Its pretty easy to avoid dynamic memory allocation by forcing a linking error when trying to link against system malloc
@traducerad don't worry, in practice it never works, and is some kind of wacky experimental feature not implemented by a few compilers
0
Q: How are binaries loaded in the default Arduino bootloader through USB?

MikhailI got a desktop program that interfaces with an Arduino. I need to be sure the correct program, either Processing or pre-compiled AVR binary is loaded as part of my handshake routine with the Arduino. What are the steps for initializing the download/new program loading procedure on the Arduino...

I had to get this crap working when I used an arduino
easiest thing was to just pipe to avrdude
 
 
2 hours later…
user7659542
10:32 PM
@Mikhail Did't know it was possible to do that. How can you do that? What are the keywords to google, to do this in C with gcc?
 

« first day (3625 days earlier)      last day (1308 days later) »