pc sender nxt with nxc receiver

HomeForumsMonoBrick Communication Librarypc sender nxt with nxc receiver

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #3952
    Author Image
    Bartłomiej Drozd
    Participant

    Hi.
    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

    #3953
    Author Image
    Anders Søborg
    Keymaster

    Hi

    I think that your problem is already described in this post

    Hope this helps

    Anders

    #3954
    Author Image
    Bartłomiej Drozd
    Participant

    Unfortunately, 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

    #3955
    Author Image
    Anders Søborg
    Keymaster

    Hi

    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

    #3956
    Author Image
    Bartłomiej Drozd
    Participant

    but 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.

    #3957
    Author Image
    Bartłomiej Drozd
    Participant

    Or 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

    #3958
    Author Image
    Bartłomiej Drozd
    Participant

    ok, 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);
    #3966
    Author Image
    Anders Søborg
    Keymaster

    Hi

    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

    #5628

    Can you send me the project file so I can use it?

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

Posted in

Make a donation