Arrangement of text in sketches

Guys, I’m trying to troubleshoot some issues with an RS485 network running some sketches that output data from a game to external modules. I can get it (them) working individually using USB on individual nanos, but the RS485 network there are issues with the data becoming corrupted and a slow transfer rate. I have made sure that the slaves are individually numbered, but beyond that apart from the reference to the RS485 network as opposed to the USB serial, they are essentially the same sketch.

One difference is that on the USB sketch there are indents on the void setup part as shown below

"void onCmscTxtJmrChange(char* newValue) {
lcd.setCursor(0, 0);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtJmrBuffer(0x1096, onCmscTxtJmrChange);

void onCmscTxtChaffFlareChange(char* newValue) {
lcd.setCursor(8, 0);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtChaffFlareBuffer(0x108e, onCmscTxtChaffFlareChange);

void onCmscTxtMwsChange(char* newValue) {
lcd.setCursor(0, 1);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtMwsBuffer(0x12b0, onCmscTxtMwsChange);"

whereas on the RS485 sketch the indents disappeared

"
void onCmscTxtJmrChange(char* newValue) {
lcd.setCursor(0, 0);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtJmrBuffer(0x1096, onCmscTxtJmrChange);

void onCmscTxtChaffFlareChange(char* newValue) {
lcd.setCursor(8, 0);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtChaffFlareBuffer(0x108e, onCmscTxtChaffFlareChange);

void onCmscTxtMwsChange(char* newValue) {
lcd.setCursor(0, 1);
lcd.print(newValue);
}
DcsBios::StringBuffer<8> cmscTxtMwsBuffer(0x12b0, onCmscTxtMwsChange);"

I believe that this should not make any difference, can you confirm?

Also, I notice that in some sketches a library will be highlighted in red, yet in another sketch it stays black - is there any significance?

Thanks

Les

Hello Les,
Please read ‘how to use this forum - please read’ especially item 7, then edit your post with the code in code tags.

The indenting of the code is to make it easy to read and follow, it does not affect what it does.

I find a strange disconnect between what you have built and what you are asking; building an RS485 network seems to me an advanced kind of project, asking about indent of text is a beginner’s question. I infer therefore that you are a beginner and the network is not your creation and you don’t really understand how it works. Is this fair?

For me or anyone to provide useful help you will need to provide a lot more information such as the code on each module, component lists, circuit diagrams and photos of what you have built.

You're correct in saying I'm new to using Arduinos, and that the things that I am using have been developed by others for us newbies to use. DCS Bios has been developed for expressly that purpose. However, the analogy I can point to is that you drive a car, yet you did not develop the car or its subsystems, but that shouldn't stop you from asking how certain things function. Being over 50 means I have come late to the party and so don't have a background in programming and computers, so please excuse my ignorance. However where I can I would like to be able to use what other people have worked hard to provide for others. Sometimes that results in questions.

I actually discovered that the mega that I was using as the master had the RX and TX pins transposed (or at least the pin naming printed on the Mega board ), which was causing the issue; there is no way that anyone other than me could have deduced that, and I only found that out when trying to make a shield PCB for the master MAX 487 chip. As I had a diferent Mega that I am using for CNC machining, I used it for comparison. Serendipity, to be sure, nonetheless I found the cause.

I wasn't asking for troubleshooting info, I was trying to verify how the formating affects the sketches - you clearly answered that, thank you for confirming that for me

Cheers for the assistance

Les

You're correct in saying I'm new to using Arduinos

Good! I hope you have ages and ages of fun with them!

Being over 50 means I have come late to the party and so don't have a background in programming and computers, so please excuse my ignorance.

Never too late to learn! No criticism intended, I was just trying to understand what your knowledge is. There seemed to be a disconnect between what you were doing and what you were asking.

Cheers for the assistance

My pleasure!

c is almost completely blind to “whitespace”. As one simple example, this code will compile just fine:

#include <stdio.h>
#define Q r=R[*p++-'0'];while(
#define B ;break;case
char*s="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[Q<nbj\
o)*|gps)<<*txjudi)m*|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q\
\ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T\
Qs\\q,,^>m,2<m>aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\
R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\
\\(aP3Q(^*m>g\\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#-aP1Q*aHb%#Qqvut)\
aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";k;char R[4][99]
;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v
[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF
&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-6);}*r=0
B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0'
)(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G':k= *p;G:p=s;while(
*p!='

Regards,
Ray L.||p[1]!= k)p++;p++B’N’:R[*p-‘0’][0]++;}}}


Regards,
Ray L.