0

Start Edit

I'm connecting the Pi directly to my PC with an ethernet cable.

End Edit

I'm trying to share a folder that's on a Raspberry Pi (running Jessie Lite) with my laptop (running Windows 7) so I can use Node.js to write a simple text file to it.

I set up samba on the Pi in the following way:

$ sudo apt-get install samba samba-common-bin
$ sudo vi /etc/samba/smb.conf

and in smb.conf made sure the following lines were like so:

workgroup = WORKGROUP
wins support = yes

and added the directory I want to share:

[pihome]
   comment= LED SW UI Home
   path=/home/ledswui
   browseable=yes
   writeable=yes
   only guest=yes
   create mask=0777
   directory mask=0777
   public=yes

Then I did:

$ sudo smbpasswd -a pi

and typed in a password (although I'm setting public = yes, so that's probably redundant, but why not?).

Then I made the directory I want to share:

$ cd /home
$ sudo mkdir ledswui/
$ sudo chmod 777 ledswui/

I'm just using this individually for a fun project so I don't really mind setting permissions to 777.

With my eth0 settings like so in /etc/network/interfaces:

auto eth0
iface eth0 inet dhcp

I reboot the Pi, login, then connect with an ethernet cord to my Windows 7 machine. I can see the Pi (\\RASPBERRYPI) under Networks > Computers. I also see it pop up when I type net view into command prompt. However, after a few seconds I notice that, in the "Network and Connections" dialog, the "Local Area Connection" adapter drops the connection. I have to disable and re-enable "Local Area Connection" again. After being re-enabled, it says "Identifying..." and I again see the Pi on the "Networks" tab under "Computers", next to my PC. But then "Local Area Connection" switches to "Unidentified network" and the Pi disappears. Process repeats. Because of all this I can't access the Pi to write files to it.

For example, in Node.js, I try:

const exec = require('child_process').exec;
exec('net view', function(error, stdout, stderr) {
    if (stdout.indexOf('RASPBERRYPI') > -1) {
        saveFile("//RASPBERRYPI/test.txt", "hi");
    }
    if (error !== null) {
        console.log(error);
    }
});

and get:

Uncaught Error: UNKNOWN: unknown error, open '\\RASPBERRYPI\test.txt\'

Even though the Pi's shared folder shows up for a few seconds (during which I call the above Node.js script), I still get that error.

Anyone know why Windows 7 is dropping the Pi's shared folder? Is that what's causing Node.js to have issues writing files to the Pi, even though the Pi appears to connect for a brief moment?

0

The key point here is:

it says "Identifying..." and I again see the Pi on the "Networks" tab under "Computers", next to my PC. But then "Local Area Connection" switches to "Unidentified network" and the Pi disappears.

which means that the connection itself is bad, not the Pi. If the Pi was bad, you would simply fail to connect to it and your network is just A-OK, but since your PC is also complaining, the network itself is bad.

This sounds like a router/switch/Ethernet cable issue.

  • Try a different, good cable. If it's the same, proceed to second bullet.
  • Try using another router/switch. If you don't have a spare router/switch, borrow one from your neighbor for about 30 minutes.
    • If it's still the same, your PC's networking hardware is bad.
    • If everything works, factory reset your existing router/switch. If the problem is still present, get a new one.

You could also test by connecting the Pi directly to your PC using an Ethernet cable and properly configuring the direct connection, but network configuration is outside the scope of this question so I'll leave it to your Google skills how.

  • Oh no....this is completely my bad. I didn't mention I'm directly connecting the ethernet cable from the Pi to my PC. The Pi is able to access the internet when I plug an ethernet cable directly from the Pi to the router. – Ryan Schuster Apr 28 '16 at 14:41
  • @RyanSchuster Did you configure it properly? Also, about how old is your PC/network card? A model number would help. – Gene Apr 29 '16 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.