Raspberry PiでWindows10のファイル共有場所に直接写真を保存したいです。
解決したいこと
Raspberry PiでWindows10のファイル共有場所に直接写真を保存したいです。
発生している問題・エラー
Python 3.9.2 (/usr/bin/python3)
>>> %Run camera3.py
Traceback (most recent call last):
File "/home/admin/ドキュメント/camera3.py", line 44, in <module>
conn.storeFile('/フォルダ名',item,file)
File "/home/admin/.local/lib/python3.9/site-packages/smb/SMBConnection.py", line 376, in storeFile
return self.storeFileFromOffset(service_name, path, file_obj, 0, True, timeout, show_progress = show_progress, tqdm_kwargs = tqdm_kwargs)
File "/home/admin/.local/lib/python3.9/site-packages/smb/SMBConnection.py", line 408, in storeFileFromOffset
self._pollForNetBIOSPacket(timeout)
File "/home/admin/.local/lib/python3.9/site-packages/smb/SMBConnection.py", line 649, in _pollForNetBIOSPacket
self.feedData(data)
File "/home/admin/.local/lib/python3.9/site-packages/nmb/base.py", line 54, in feedData
self._processNMBSessionPacket(self.data_nmb)
File "/home/admin/.local/lib/python3.9/site-packages/nmb/base.py", line 75, in _processNMBSessionPacket
self.onNMBSessionMessage(packet.flags, packet.data)
File "/home/admin/.local/lib/python3.9/site-packages/smb/base.py", line 150, in onNMBSessionMessage
if self._updateState(self.smb_message):
File "/home/admin/.local/lib/python3.9/site-packages/smb/base.py", line 344, in _updateState_SMB2
req.callback(message, **req.kwargs)
File "/home/admin/.local/lib/python3.9/site-packages/smb/base.py", line 1158, in connectCB
errback(OperationFailure('Failed to store %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
File "/home/admin/.local/lib/python3.9/site-packages/smb/SMBConnection.py", line 402, in eb
raise failure
smb.smb_structs.OperationFailure: Failed to store 20230217_173138.jpeg on /ファイル名: Unable to connect to shared device
==================== SMB Message 0 ====================
SMB Header:
-----------
Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0x00000000
Flags: 0x00
PID: 2684
MID: 3
TID: 0
Data: 66 bytes
b'0900000048003a005c005c004400450053004b0054004f0050002d00470035004d0043005100390037005c002f001a904e90426699511f772f003100ec30fc30f330'
SMB Data Packet (hex):
----------------------
b'fe534d42400000000000000003000000000000000000000003000000000000007c0a0000000000005900000c00280100000000000000000000000000000000000900000048003a005c005c004400450053004b0054004f0050002d00470035004d0043005100390037005c002f001a904e90426699511f772f003100ec30fc30f330'
==================== SMB Message 1 ====================
SMB Header:
-----------
Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0xC00000CC
Flags: 0x01
PID: 2684
MID: 3
TID: 0
Data: 8 bytes
b'0900000000000000'
SMB Data Packet (hex):
----------------------
b'fe534d4240000000cc0000c003000100010000000000000003000000000000007c0a0000000000005900000c00280100000000000000000000000000000000000900000000000000'
>>>
該当するソースコード
#Import Files
import RPi.GPIO as GPIO
import picamera
import time
import platform
from smb.SMBConnection import SMBConnection
#GPIO Settings
GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#Camera Settings
if __name__ == "__main__":
# connection open
conn =SMBConnection(
'user',
'pas',
platform.uname().node,
'コンピューター名',
domain='WORKGROUP',
use_ntlm_v2=True)
conn.connect('ip', 139)
camera = picamera.PiCamera()
camera.shutter_speed = 600
#Main
try:
while True:
if GPIO.input(26) == 0:
filename = time.strftime("%Y%m%d")+"_"+time.strftime("%H%M%S") + ".jpeg"
camera.capture(filename)
item = filename
with open(item) as file:
conn.storeFile('/フォルダ名',item,file)
except KeyboardInterrupt:
GPIO.cleanup()
conn.close()
自分で試したこと
Pythonは今日初めて触りましたのでイマイチ勝手がわからず、すみません、何も試せていません。
よろしくお願いいたします。
1