Sending a file in NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
dudmaster
Posts: 171
Joined: 06 Oct 2010, 02:38
Location: Texas, Santa Fe
Contact:

Sending a file in NXC

Post 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-)
2Labz.com, My Website
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: Sending a file in NXC - update

Post 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!
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Sending a file in NXC

Post 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?
Last edited by muntoo on 08 Feb 2011, 00:19, edited 5 times in total.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Sending a file in NXC

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Sending a file in NXC

Post 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?
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Sending a file in NXC

Post 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.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Sending a file in NXC

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Sending a file in NXC

Post 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?
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Sending a file in NXC

Post 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?
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Sending a file in NXC

Post 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.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 2 guests