Dual Network Nodes! (Final Project R&D)
My final project is going to be made of a "large" network of processors (i.e. 10 or so) on a single board, and each of those processors will have the possibility of having other processors attached to them in a way that only they can see. In other words, each processor would be on one common network, but would also support their own private message network.
This week, in addition to just getting a single network up and running, I wanted to explore that concept. I re-used some of the programming pins for my second set of TX/RX, which meant I could "plug in" nodes by connecting to the ISP pins.
Node Types
I milled several types of node, although I was only able to code up three of them:
- Controller node - this node tells the message when to talk, collects their responses, and sends them to the computer.
- Message node - this node acts as the standardized liasan between the information nodes and the controller node. They listen for requests from the controller, and when they get a request they poll their attached information node for the details of their message.
- Information and Trigger nodes (button, light) - these nodes act differently depending on whether or not they are connected to a controller or a message node. If connected to a controller, they will trigger that controller to collect data (i.e. you push a button to trigger it, or the lights go on or off). If connected to a message node they will track a dynamic message and listen for information requests.
I was able to mill all three (Controller and Message nodes are physically the same right now, although that will soon change). I got my network to work, and I even got my trigger / controller interaction up and running. Unfortunately it all stopped there for this week because.....
Strings! Egads!
My nodes pass dynamic messages back and forth, so I need to be able to dynamically send strings. Unfortunately, this is apparently not a simple matter of looping through the characters in a string and put_char-ing them.
Here's what I tried, and these strings aren't even dynamic! (sort of pseudocode, I'm not copying from my code base):
char * str = "test"; char chr; int i = 0; for(i = 0; i <4 ; ++i) { chr = str[i]; put_char(*port,pin,chr); } ^ Yields "ÿÿÿÿ" ------------------------------ char * str = "test"; char chr; int i = 0; for(i = 0; i <4 ; ++i) { chr = str[2]; put_char(*port,pin,chr); } ^ Yields "ssss" ------------------------------ char * str = "test"; char chr; int i = 0; int x = 2; for(i = 0; i <4 ; ++i) { chr = str[x]; put_char(*port,pin,chr); } ^ Yields "ssss" ------------------------------ char * str = "test"; char chr; int i = 0; int x = 0; for(i = 0; i <4 ; ++i) { chr = str[x]; put_char(*port,pin,chr); ++x; } ^ Yields "ÿÿÿÿ" ------------------------------ char * str = "test"; char chr; int i = 0; int x = 0; for(i = 0; i <4 ; ++i) { if(x == 0) chr = str[0]; if(x == 1) chr = str[1]; if(x == 2) chr = str[2]; if(x == 3) chr = str[3]; put_char(*port,pin,chr); ++x; } ^ Yields "test" ------------------------------ char * str = "test"; put_str(*port, pin, str); ^ Yields all SORTS of insanity
Anyone? Does anyone have a clue what's up?