Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Barnyard Protein posted:

as much as possible of the app will be in java with spring mvc, but i would like to have some ~dynamic web interfaces~. i'm starting to think that having content update without a page reload isn't worth loving around with javascript and jquery

just write a java applet

Adbot
ADBOT LOVES YOU

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

on a related note today I got a job. I'm a node.js developer now :shrug:

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Symbolic Butt posted:

on a related note today I got a job. I'm a node.js developer now :shrug:

rip

Shaggar
Apr 26, 2006

Barnyard Protein posted:

i'm starting to think that having content update without a page reload isn't worth loving around with javascript and jquery

the student becomes the master.

Notorious b.s.d.
Jan 25, 2003

by Reene

Barnyard Protein posted:

as much as possible of the app will be in java with spring mvc, but i would like to have some ~dynamic web interfaces~. i'm starting to think that having content update without a page reload isn't worth loving around with javascript and jquery

vaadin

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Symbolic Butt posted:

on a related note today I got a job. I'm a node.js developer now :shrug:

similarly, i've been promoted from guy who reports bugs to guy who bugs get reported to

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Luigi Thirty posted:

similarly, i've been promoted from guy who reports bugs to guy who bugs get reported to

i asked on slack today who our security person was and was insta promoted to vice president of operational security (no raise)

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Barnyard Protein posted:

re: web dev

how can you mock out a get/post API? is there something like java's mockito

JavaScript code:
when("thing/stuff?blerp=hello").thenReturn("<h1>HELLO</h1>"); //mockito pseudocode
when("thing/stuff?blerp=byebye").thenReturn("<h1>BYEBYE</h1>");
$("#bleh").load("thing/stuff?blerp=hello") // loads <div id='bleh'/> with <h1>HELLO</h1>

sinon?

Luigi Thirty
Apr 30, 2006

Emergency confection port.

the talent deficit posted:

i asked on slack today who our security person was and was insta promoted to vice president of operational security (no raise)

I wish I knew who our security guy was because I've seen some things

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Luigi Thirty posted:

I wish I knew who our security guy was because I've seen some things

...things you people wouldn't believe. aws credentials in commits on github. i watched ansible roles copy ssl certs to publically accessible s3 buckets. all those passwords will be lost to hackers like bitcoins on mtgox. time to resign

Luigi Thirty
Apr 30, 2006

Emergency confection port.

basically that yes

Papes
Apr 13, 2010

There's always something at the bottom of the bag.

the talent deficit posted:

...things you people wouldn't believe. aws credentials in commits on github.

this happened in my senior year of college. this guy in our group had never used git before and he ended up committing files that had our credentials in it.

Amazon called him within 24 hours and told him not to do that poo poo again.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Luigi Thirty posted:

similarly, i've been promoted from guy who reports bugs to guy who bugs get reported to

congratulations, another entry for #P"Documents:YOSPOS;Success Stories.TEXT.NEWEST"

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

the talent deficit posted:

...things you people wouldn't believe. aws credentials in commits on github. i watched ansible roles copy ssl certs to publically accessible s3 buckets. all those passwords will be lost to hackers like bitcoins on mtgox. time to resign

gonadic io
Feb 16, 2011

>>=
terrible programmer status: i need some help with intellij. i have my module, CPU. however when there's a CPU module and a root module*

when both root and cpu modules exist, then i get the compilation error:

quote:

Error:scalac: Output path C:\Users\gonadic io\IdeaProjects\CPU\target\scala-2.11\test-classes is shared between: Module 'CPU' tests, Module 'root' tests
Output path C:\Users\gonadic io\IdeaProjects\CPU\target\scala-2.11\classes is shared between: Module 'CPU' production, Module 'root' production
Please configure separate output paths to proceed with the compilation.
TIP: you can use Project Artifacts to combine compiled classes if needed.

and if i delete the module root, then it gets recreated on intellij start up.

should i only be using root? i don't really know what's going on

*: like so


e: i guess just keeping the root module and getting rid of the cpu one fixes it. i don't really know the difference between modules and projects, or why you'd want multiple modules in a project, but whatever #worksforme

gonadic io fucked around with this message at 14:55 on Aug 8, 2015

Luigi Thirty
Apr 30, 2006

Emergency confection port.

so I have a KSP plugin that talks to my Arduino with a two-line LCD screen. my Arduino understands three commands over serial: write a string to line 1, write a string to line 2, and clear the screen.

problem is, since the way it processes commands is by shoving incoming ASCII data into a buffer and waiting for a CRLF sequence, if a second command comes in while we're still processing the first command (I want to write altitude to the top line and velocity on the bottom line), the buffer is corrupted and the program will crash. what's the name for this beyond "bad at systems programming"

oh no blimp issue
Feb 23, 2011

wait, is your buffer just like 8 characters long or something? are we talking about the serial buffer on the arduino or the transmission buffer on the thing that's talking to the arduino

Luigi Thirty
Apr 30, 2006

Emergency confection port.

i have an ISR that takes each character that comes in over the wire and puts them in a 64-byte buffer, then executes the command when it sees a CRLF sequence or discards it if the buffer is full with no CRLF. this may not be ideal. each of the three commands consists of a three-character mnemonic followed by the string if required.

Luigi Thirty fucked around with this message at 23:53 on Aug 8, 2015

Jerry Bindle
May 16, 2003
you need some kind of protocol that handles new incoming commands such that they don't corrupt commands being processed. at a basic level, this could take form of adding a new command that asks/answers "are you busy, can i send a new command?"

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Luigi Thirty posted:

i have an ISR that takes each character that comes in over the wire and puts them in a 64-byte buffer, then executes the command when it sees a CRLF sequence or discards it if the buffer is full with no CRLF. this may not be ideal. each of the three commands consists of a three-character mnemonic followed by the string if required.

why use a three char mnemonic? you could shove the command and the string length in a single byte

oh no blimp issue
Feb 23, 2011

send commands until the buffer is full, if a command comes in while the buffer is full just delete the entire buffer and start again, stuff in the buffer wasn't important anyway

b0lt
Apr 29, 2005

Luigi Thirty posted:

i have an ISR that takes each character that comes in over the wire and puts them in a 64-byte buffer, then executes the command when it sees a CRLF sequence or discards it if the buffer is full with no CRLF. this may not be ideal. each of the three commands consists of a three-character mnemonic followed by the string if required.

use a ring buffer with a read and write pointer and hope (or ensure) that the pointers never cross each other

Jerry Bindle
May 16, 2003
you could also implement a command queue. if a command is being processed, new incoming commands get added to the queue. when the lcd is ready to process a new command it pops it off the queue and begins work. this will stop working if you send commands too fast and fill up your queue. the "busy" logic will have to take place somewhere: explicitly through a command that determines if the lcd is free, implicitly through some convention (e.g. only send x commands/sec), etc.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

eschaton posted:

why use a three char mnemonic? you could shove the command and the string length in a single byte

so that when i'm debugging it i can just open up a serial console and type commands in.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
also maybe rate limit the plugin. exactly how often are you trying to refresh this that you're running into this issue

Luigi Thirty
Apr 30, 2006

Emergency confection port.

once per second, so that's not the issue

okay, i implemented a command queue and it works great, for a while. the problem is that it's leaking memory! :suicide: after a number of commands which are processed successfully, when I echo the command back after it's popped from the queue, the command text is just garbage or strings from RAM and it crashes. i know the command length being written into the queue is correct (strlen(command_buffer) is always correct, but when the command is popped it's an empty string or garbage), so it's being mangled while it's queued somehow. uhhh can someone tell me if anything's obviously wrong here?

code:
struct CommandNode {
	char text[64];
	CommandNode *next;
};

class CommandQueue {
	public:
	CommandNode *root;

	CommandQueue(){

	}

	void Push(char* buf)
	{
		//Put the new node before the root node. The new node is the new root.
		CommandNode *node = new CommandNode; //malloc

		node->next = root;
		strcpy(node->text, buf);
		root = node;
	}

	void Pop(char* buf)
	{
		//Return the first entry from the queue.
		CommandNode *temp;
		temp = root->next;
		
		strcpy(buf, root->text);
		delete(root); //free
		root = temp;
	}

	bool IsEmpty()
	{
		if (root == NULL)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
};
popping a command is just doing .Pop into a char array of the correct size, and then the command is echoed to the console (where it is incorrect) and passed to process_command().

my ISR is just

code:
ISR(USART_RX_vect){
	char data = UDR0; //incoming character
	
	if(data != '\r' && data != '\n') //don't write \r\n to the command buffer
	{
		command_buffer[strlen(command_buffer)] = data;
		command_buffer[strlen(command_buffer) + 1] = '\0';
	}
	
	if(data == '\n'){ //but \n signals the end of a command
		command_buffer[21] = '\0'; //sanity
		USART_Send_int(strlen(command_buffer)); //this is always correct
		commandQueue.Push(command_buffer);
		memset(command_buffer, '\0', 64); //empty the buffer
	}
}

Luigi Thirty fucked around with this message at 04:36 on Aug 9, 2015

Corla Plankun
May 8, 2007

improve the lives of everyone

Luigi Thirty posted:

so I have a KSP plugin that talks to my Arduino with a two-line LCD screen. my Arduino understands three commands over serial: write a string to line 1, write a string to line 2, and clear the screen.

problem is, since the way it processes commands is by shoving incoming ASCII data into a buffer and waiting for a CRLF sequence, if a second command comes in while we're still processing the first command (I want to write altitude to the top line and velocity on the bottom line), the buffer is corrupted and the program will crash. what's the name for this beyond "bad at systems programming"

why are you doing this with an isr instead of the normal arduino serial library and peek()?

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

isn't strcpy deprecated because of buffer overruns? idk if the problem is that but sounds like a good thing to look up

b0lt
Apr 29, 2005

Luigi Thirty posted:

uhhh can someone tell me if anything's obviously wrong here?

Are you calling malloc in an ISR? :psyduck:

Jerry Bindle
May 16, 2003
its too late for me to try to be confident in my ability to check linked-list code. it looks right, but idk.

i have some general embedded advice though. find a unit testing framework that you like, and write as much as code as possible such that it will compile/execute/test on your workstation with gcc or clang or whatever. once you have your queue implementation solid, incorporate it with your firmware. the most aggravating thing (to me) about embedded development is how one broken piece can cause the whole system to malfunction to a point where its difficult to tell what the root cause is. every component that you can guarantee as working will save you a lot of work down the road

Jerry Bindle
May 16, 2003
oh also, i'll mention something way outside what the likely root-cause is, or something you care to gently caress around with it but could possibly affect the correct operation of your project.

the real world is analog, your serial communication isn't guaranteed to reach its destination uncorrupted! its hooked up to your computer right, so there are probably some electrically noisy things around. the computer itself shouldn't be a concern, but if there are switching power supplies, powerful motors, &c. near then you may get the occasional corrupted byte on the serial line. your code as it stands assumes that it receives the data that you send it. what if instead of an '\n', the part receives '\n' with a random bit flipped? well, in this case you could enable the UART module's parity bit checking and you could detect a single bit error. what if two bits get flipped? now you need a more complicated solution. the error code correction/detection field is very rich with solutions to this kinds of problems, a basic solution would be to take the CRC of the packet on the sender and send it along in the packet. the receiver would check the CRC and decide what to do if it doesn't match.

Jerry Bindle fucked around with this message at 06:50 on Aug 9, 2015

ConanTheLibrarian
Aug 13, 2004


dis buch is late
Fallen Rib
echoing error checking as a possible culprit


also did you intend to implement a stack? a FIFO queue is probably what ur after

Lime
Jul 20, 2004

Luigi Thirty posted:

code:
	if(data != '\r' && data != '\n') //don't write \r\n to the command buffer
	{
		command_buffer[strlen(command_buffer)] = data;
		command_buffer[strlen(command_buffer) + 1] = '\0';
	}

you're overwriting the null byte that strlen looks for with the first line, so the second strlen is in general a random number but i guess you're getting lucky for a while that all your buffers are in zeroed memory

just save the strlen in a int beforehand, use that twice

Bloody
Mar 3, 2013

are you doing dynamic memory allocation on an arduino

lol

hobbesmaster
Jan 28, 2008

Bloody posted:

are you doing dynamic memory allocation on an arduino

lol

it has 2kB of RAM

Luigi Thirty
Apr 30, 2006

Emergency confection port.

this is web developer c okay i don't know what i'm doing

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
you need to initialize your variables. initialize root to null in your constructor. also realize that your isempty check will break because calls to delete will not set the pointer to null, only deallocate the memory it points to. you need to do
code:
 delete foo; foo=nullptr; 
at all times.\

also:
1. do not do malloc in an isr. things in isrs should be as quick as possible. this isn't an issue in this case because it's a trivial example but please just do not do it. let that isr just put data in a buffer, and set a flag when it gets a \n so code running in normal context can process the buffer.
2. this command buffer doesn't need to be dynamically allocated, unless i guess you really want to figure out how to do cpp dynamic allocation, which is an ok goal.
3. seriously, if you're only sending this data once per second, needing a command buffer at all is a sign that something else in your code is seriously screwed up. since you're writing this directly in c++ rather than arduino's intermediate, write a really light stub for a hal and isrs and compile it with your system compiler so you can use gdb or valgrind. or hell just download atmel studio, atmel's VS skin http://www.atmel.com/tools/atmelstudio.aspx for free, buy a jtagice (not free but v useful) and do things the big boy way.

oh no blimp issue
Feb 23, 2011

on that note of doing c++ directly to arduino, how the gently caress do you do that? ive tried before with atmel studio but poo poo didn't work

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Awia posted:

on that note of doing c++ directly to arduino, how the gently caress do you do that? ive tried before with atmel studio but poo poo didn't work

what didn't work about it? atmel studio is pretty good about that, just make sure you've selected a c++ project. you might have to stub out some syscalls like __cxa_guard_aquire and such, but it's pretty easy to google the errors you get.

Adbot
ADBOT LOVES YOU

oh no blimp issue
Feb 23, 2011

i tried to move a .ino from arduino to atmel, so got the c++ intermediate it creates and everything, moved it to atmel, included all the arduino libraries and poo poo and it just shat errors all over me. ill give it another go later and see what they were

  • Locked thread