Home→Forums→MonoBrick Communication Library→pc sender nxt with nxc receiver
- This topic has 8 replies, 3 voices, and was last updated 7 years, 11 months ago by Joshua Peterson (jpcreeper13).
-
AuthorPosts
-
February 9, 2014 at 11:25 #3952
Bartłomiej DrozdParticipantHi.
I need to make one-way communication between pc and nxt brick. I do simple program at pc to send string to brick and program in nxc to receive that string. It’s ok, but i can only one send string to brick, after that brick doesn’t want to receive next string. I use that in c#string command = Console.ReadLine(); brick.Mailbox.Send(command, Box.Box0);
and that in nxc
string a; while(true) { ReceiveRemoteString(0, 0, a); TextOut(0, LCD_LINE2, a); }
when i do program in nxt-g it’s work fine, but i must to do it in nxc. Please, help me with this
February 9, 2014 at 11:31 #3953
Anders SøborgKeymasterFebruary 9, 2014 at 11:42 #3954
Bartłomiej DrozdParticipantUnfortunately, that not solved my problem. I send from pc string to mailbox 0 and in brick i receive string from mailbox 0. First time that work great, but when i try to send next string to the same mailbox that didn’t work. When i close program in brick and run it again, then i can again send one string and it’s a loop… when i do program in nxt-g i send from pc string to mailbox 0 and receive in brick from mailbox 1 and that work fine. I don’t know what is wrong
February 9, 2014 at 11:46 #3955
Anders SøborgKeymasterHi
Ok since it is working in NXT-G – there must be a problem in your NXC code… what does the docs say about
ReceiveRemoteString(0, 0, a); ?
Anders
February 9, 2014 at 11:53 #3956
Bartłomiej DrozdParticipantbut when i do second sender program in second brick work fine at the same mailbox.
ReceiveRemoteString(queue, remove, out strval)
This method is used on a master brick to receive a string value from a slave device
communicating via a specific mailbox or message queue. Optionally remove the last
read message from the message queue depending on the value of the boolean remove
parameter.February 9, 2014 at 12:03 #3957
Bartłomiej DrozdParticipantOr maybe You could help mi with c++ library? I need to make one-way communication pc -> nxt with camera vision and i have finished program to camera vision in c++, without communication between pc and nxt. I need to send some string messages to difefrent mailbox. I don’t know how to use Your c++ library to send bt or usb messages to default mailbox
February 9, 2014 at 12:59 #3958
Bartłomiej DrozdParticipantok, i solved this problem. I noticed, i must to send 5 times the same string to nxt, then nxt receive it correctly.
In c# it’s look that:bool f = true; Console.WriteLine("Y: "); data = Int32.Parse(Console.ReadLine()); command = data.ToString(); if (f == true) //because first time send correctly { brick.Mailbox.Send(command, Box.Box1, false); f = false; } brick.Mailbox.Send(command, Box.Box1, false); brick.Mailbox.Send(command, Box.Box1, false); brick.Mailbox.Send(command, Box.Box1, false); brick.Mailbox.Send(command, Box.Box1, false); brick.Mailbox.Send(command, Box.Box1, false); brick.Mailbox.Send(command, Box.Box1, false); Console.WriteLine("Y pos: " + command);
February 13, 2014 at 19:59 #3966
Anders SøborgKeymasterHi
I think that this is a timing issue… It seems wrong that you need to send the same string five times – this is not a fix. Like I said there must be something that you are doing wrong in your NXC program since the NXC code and NXT-G compiles to the same byte-code….
I can’t remember NXC but does strings in NXC have variable length? or do you need to specify the length when you create a string?
Anders
January 21, 2017 at 21:13 #5628
Joshua Peterson (jpcreeper13)ParticipantCan you send me the project file so I can use it?
- This reply was modified 7 years, 11 months ago by Joshua Peterson (jpcreeper13).
-
AuthorPosts
You must be logged in to reply to this topic.
Follow