I’m relatively new to URCap but use a UR10 CB3.3 for a longer time now.
My team and I want to develop a solution with which we can create a “logfile” with a position and DI’s and DO’s per line. Surprised by not finding such functionality in the core we thought of developing a URCap.
I found the XML-RPC Math URCap and thought that could help to append lines to a textfile like so:
File(message):
with open(filePath, 'a+') as file:
file.write(message, "\n")
My Problem now is that I don’t know how to save this file to a USB-stick. My preferred solution would be an appearing save file dialog when I press an own HTML Button or something like this.
Maybe someone has done this before and/or can me help.
Please, any suggestions/solutions are highly appreciated.
I’m sure some of our more Java savvy friends can tell you how to make a more flexible solution using JFileChooser, but for a very simple python-centric approach you could just have a “Save to USB” button in your plugin GUI, that uses xmlrpc to call a python function that copies the log file into the USB which is auto mounted at /programs/usbdisk
I am using a simple python-centric approach to copy a log file to the USB disk. The problem I am having is that even when a USB disk is not plugged in, I can still copy files to the /programs/usbdisk location. Is there a way to check if a USB disk is actually plugged in before copying files?
The /programs/usbdisk location is just a symbolic link to the disk, it’s actually mounted in the /media directory.
I don’t have a real robot infront of me now, but I think it mounts the disk in that directory with an auto generated name starting with “ur”. So you could check if the /media directory contains something with a name like that, and if so, proceed with your write operation:
import os
disks = os.listdir('/media')
for d in disks:
if 'ur' in d:
#proceed to write file