Page 1 of 2

Sending a file in NXC

Posted: 29 Jan 2011, 21:36
by dudmaster
Can you send a file through Bluetooth in NXC? Something like "SendFile()"?

-Dud

I got my name changed. I like it better 8-)

Re: Sending a file in NXC - update

Posted: 29 Jan 2011, 22:45
by h-g-t
Don't know about a file but Philo built a joystick which links 2 nxt units using nxt-g so there must be some useful hints there (http://www.philohome.com/nxtjoystick/joystick.htm). I know someone was sending info using lejos because I cane across a reference to it - google is your friend.

Have just found some info about bt communication on this website http://robotics.benedettelli.com/BT_NXC.htm. Just going to download and read it myself!

Re: Sending a file in NXC

Posted: 05 Feb 2011, 01:28
by muntoo
dudmaster wrote:Can you send a file through Bluetooth in NXC? Something like "SendFile()"?
Check out INTF_SENDFILE or INTF_SENDDATA.

Use it with CommExecuteFunctionType.

[Edited]

Code: Select all

#define BT_CONN 1

task main()
{
    CommExecuteFunctionType args;
    args.Cmd = INTF_SENDFILE;
    args.Param1 = BT_CONN;
    args.Name = "virus.rxe";
    SysCommExecuteFunction(args);
}
My name is chicken wrote:I got my name changed. I like it better 8-)
Isn't that illegal? Did your parents approve? Or are you secretly 42 years old?

Re: Sending a file in NXC

Posted: 07 Feb 2011, 18:49
by afanofosc
The INTF_SENDFILE function also requires that you tell it the name of the file you want to send via the Name field in the CommExecuteFunctionType structure. This should work just like it does when you use the UI menu system to send a file from one NXT to another.

John Hansen

Re: Sending a file in NXC

Posted: 09 Feb 2011, 20:05
by HaWe
is there a similar way to send a file to a PC via USB?
How has the destination path to the target directory to be specified?

Re: Sending a file in NXC

Posted: 10 Feb 2011, 01:26
by muntoo
doc-helmut wrote:is there a similar way to send a file to a PC via USB?
How has the destination path to the target directory to be specified?
You could look into the Fantom SDK stuff (or whatever, I think that's what it's for..., right?), if you want to download from the PC.

Re: Sending a file in NXC

Posted: 10 Feb 2011, 04:00
by afanofosc
There is no automatic way to send a file from the NXT to a PC via USB. You need to have a program running on the PC use various system commands over a USB connection to read the file from the NXT and write it to the PC. I guess you could open a file and then start writing to the USB output buffer but that would not do anything unless you have a custom written program running on your PC to do something with the data on the USB connection.

I understood the original question to be about sending a file from one NXT to another but if it was about sending a file to a PC then the comm module function Muntoo mentioned will not work.

John Hansen

Re: Sending a file in NXC

Posted: 10 Feb 2011, 07:29
by HaWe
ok, thx, I see.
Maybe there is someone around who once has written such a program for the PC to pick up a file from NXT and store it in a PC folder?

Re: Sending a file in NXC

Posted: 11 Feb 2011, 03:29
by muntoo
doc-helmut wrote:ok, thx, I see.
Maybe there is someone around who once has written such a program for the PC to pick up a file from NXT and store it in a PC folder?
You mean NeXTExplorer? Maybe John could provide some source code/link?

Re: Sending a file in NXC

Posted: 11 Feb 2011, 07:54
by HaWe
muntoo,
no, what I mean are program(s) which let me automatically store a file (created by my NXC program) into a PC folder (sent by USB), e.g. every time when I press a specific NXC button. The different file names are counted automatically like
FILE001.TXT
FILE002.TXT
FILE003.TXT
...

It's for my speech recognition program as you may guess:
I record a sound pattern
The pattern is written to a file which is stored on the flash
Next, I may press a NXT Btn to send it to the PC.
Then the file will be erased from the flash to free memory.

As I have to do it very often (60-100 times or more) the NXTexplorer is too tortuously.