Forum Replies Created
-
AuthorPosts
-
Helmut WunderParticipantwhy do you ask? you should know it, we already discussed this beyond measure –
For the EV3 there is no complete C-based API available – no sensor- and no i2c library, just a Lego lms2012 header which is bugged like hell.
I also don’t understand anything about C#, Visual Studio, WiFi, classes, objects, implementing, derivating, uses, extending –
just know something about straight procedures and functions like by ANSI C or Sketch or Pascal. OOP is simply a mess to me.But the NXC code and the Sketch code (both actually simplified procedural C) have been established by me, top-down, within a couple of days (as you know).
http://www.mindstormsforum.de/viewtopic.php?f=25&t=8302&p=65015#p65015If I knew how to do it by C# I wouldn’t have started my thread about Brick/Arduino-i2c-communication.
But as you are experienced in C# – : if it was that easy, why didn’t you proceed with your beginnings ?
Where’s the coding problem ?
Helmut WunderParticipanthey,
congratulations, this looks like a very good start!
but will you even try to establich a communication protocol for alternately, rotatory sending and receiving a data array like byte array[14] like I did in my NXC example? That would be great if we finally could access an Arduino by a EV3 similar like as it’s already possible by a NXT !http://www.mindstormsforum.de/viewtopic.php?f=25&t=8302#p65015
Helmut WunderParticipanthey,
by NXC for NXT I got it working – one just would need to transcode the NXC source into Mono/C# –
who would like to do it? 😎http://www.mindstormsforum.de/viewtopic.php?f=25&t=8302&p=65015#p65015
Helmut WunderParticipantps,
an Arduino Sketch code for i2c communication is already available, but maybe it has to be changed to work reliably with the corresponding C# code:#include <Wire.h> #define SLAVE_ADDRESS 0x04 int number = 0; int state = 0; void setup() { pinMode(13, OUTPUT); Serial.begin(9600); // start serial for output // initialize i2c as slave Wire.begin(SLAVE_ADDRESS); // define callbacks for i2c communication Wire.onReceive(receiveData); Wire.onRequest(sendData); Serial.println("Ready!"); } void loop() { delay(100); } // callback for received data void receiveData(int byteCount){ // ... maybe add a delay(15) to go easy on the i2c bus... ??? while(Wire.available()) { number = Wire.read(); Serial.print("data received: "); Serial.println(number); if (number == 1){ if (state == 0){ digitalWrite(13, HIGH); // set the LED on state = 1; } else{ digitalWrite(13, LOW); // set the LED off state = 0; } } } } // callback for sending data void sendData(){ Wire.write(number); }
so any help for Mono/C# code will be appreciated!
Thanks in advance!
Helmut WunderParticipanthow is it possible to read/write variables other than bytes dircty,
without having to rearrange and convert data from basic bytes, e.g.
int16,
int32,
float64,
strings
arrays of single data type (e.g., arrays[6] of float)
structureslike fprintf, fscanf, and fputs etc. in C:
FILE * pFile; int n; char name [100]; pFile = fopen ("myfile.txt","w"); for (n=0 ; n<3 ; n++) { puts ("please, enter a name: "); gets (name); fprintf (pFile, "Name %d [%-10.10s]\n",n,name); } fclose (pFile); //... pFile = fopen ("myfile.txt","w+"); fprintf (pFile, "%f %s", 3.1416, "PI"); rewind (pFile); fscanf (pFile, "%f", &f); fscanf (pFile, "%s", str); fclose (pFile); printf ("I have read: %f and %s \n",f,str);
Helmut WunderParticipanthopefully this will be implemented into one of the next releases (standard bmp, png, jpg)
Helmut WunderParticipantJFYI, to me it’s also important to create files by a running program, e.g., to store settings a/o data which can be reloaded and rewritten/updated .
Examples:
sound (rhythm) patterns for spoken words,
x,y,z coordinates for teached-in robot arm positions,
look-up tables of different kind,
log files of different kind,
recognized patterns by a neural net,
2D environment maps of rooms and mazes….
Helmut WunderParticipant
Helmut WunderParticipantone could take an Arduino plugged to the EV3 by i2c for doing this job 😎
USB for file upload would be appriciated, though 😉
Helmut WunderParticipantsuch a simple and easy IDE would be fine to have for Mono/EV3, too:
Attachments:
You must be logged in to view attached files.
Helmut WunderParticipantHi Anders,
for emails you might be right – but I don’t want to send emails, I need quick and straight lcd_out and motor control and sensor reading and calculations about all that without all this new instantiation of classes and objects thing even for every single pure variable in deprivation of simple and straight (global) functions and procedures.
(But I’m sure a C header file can be written which only had to be #included and even emails would be fine for C.)Instead of your code
Rectangle box = new Rectangle( new Point(0,0), new Point(20, 20)); Lcd.Instance.WriteTextBox(Font.MediumFont, box, "Test"); System.Threading.Thread.Sleep(5000); Lcd.Instance.Clear(); Lcd.Instance.WriteText(Font.MediumFont, new Point(0, 30), "Test2");
I would code
draw_rectangle(0,0,20,20); SetFont(MediumFont); printfxy(10,10,"Test"); msleep(5000); cls(); printfxy(0,30,"Test2");
I even could write my simple “write text into a box” function:
void textinbox (int b1,int b2,int b3,int b4, int t1, int t2, string msg) { draw_rectangle(b1,b2,b3,b4); printfxy(b1+t1,b2+t2, msg); } // textinbox (0,0,20,20, 0,30, "Test");// w/o that probably 20kb C# OOP code overhead
I guess my brain is actually thinking in C-like or Pascal-like procedural patterns, and using them I’m able to do quite complex things (AI, self-training neural nets, chess egine programming and this kind of stuff). I’m quite sure I won’t understand this knotty objecturalization any more, and the overcomplicated IDEs are an obstruction on a quite different addditional level which is not my world.
IMO Mono and C# and it’s environments is unfortunately more for professional programmers, not for simple leisure time home programmers- what they needed would be more like NXC or even “Turbo-Pascal for MSDOS” level. OOP is really weird to me. I think I’ll resign, the earlier the better.
Helmut WunderParticipantpuuuh.. rather complicated this new-point-box-offeset-whatever-thing.
A half side of text just for an equivalent to
TextOut(10,24,"Hello World");
?Can’t the coordinates be used by simple numbers or variables?
for (int x=0; x<8; ++x) {NumOut(x, x*10, x);}
or, more C-like, more easy and “universal” formattable
{printfxy(x, x*10, "%2d", x);}
C# seems to need 20 times more letters and lines to write as C (CMIIW)… 🙁
Helmut WunderParticipantwhat I need to have and to do is simply what BCC is featuring and providing for NXT and EV3, just:
– start the IDE with editor window
– include all existing “uses” all at once (not type the entire Encyclopedia Britannica each time at the start)
– – or: load an existing program file into the editor (via browser or recent files)– connect to brick (e.g., F3 by USB)
– write or change my program code
– fix error issues if needed (e.g., F1 for context-sensitive help)
– save as… (filename) to my code directory
– – if a different version is to be saved intermediately:
– – just again save as… (e.g. other filename to either directory)– compile to an exe file (e.g., F5)
– upload it to the EV3 (e.g., F6)
– run the program on EV3.
Just that easy….
As BCC is perfect for Mindstorms programming and BCC already can connect to EV3/Linux and it’s settings allow to target gpp CSLite it possibly might be an option to patch those settings to match to Mono/C# instead… ❓
Or maybe there is already a similar simple IDE for Mono ❓- This reply was modified 10 years, 6 months ago by Helmut Wunder.
Helmut WunderParticipantthe dll is already correctly linked by visual studio 2010
so copy the dll into what app folder exactly?EDIT 1:
Or do you mean: copy the dll to the SDcard apps folder ???
EDIT 2: yes !!! 😀
now that the monobricks.dll is in the SDCard apps folder it works!! Thank you! 😀 😀Attachments:
You must be logged in to view attached files.
Helmut WunderParticipantI surely will – ASAP, i.e.: as soon as USB file upload will be enabled 😎
-
AuthorPosts
Follow