# Saving To File

**URL:** <https://forums.openmv.io/t/saving-to-file/653>\
**Category:** OpenMV Boards\
**Created:** [April 15, 2018, 2:43am UTC](https://forums.openmv.io/t/saving-to-file/653 "2018-04-15T02:43:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpreese246](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jpreese246](https://forums.openmv.io/u/jpreese246)\
**Post date:** [April 15, 2018, 2:43am UTC](https://forums.openmv.io/t/saving-to-file/653/1 "2018-04-15T02:43:58Z")

</div>

Hello everyone. I can successfully save a barcode payload to the SD card on the OpenMV. However, my operating system does not recognize that a file has been saved on the SD card until I reset the open MV. For my application, i want to detect when a new file is present, and then perform an action. I cannot do this correctly because I have to cycle power to the OpenMV camera to recognize that a new file has been created.

Is there a way in Micropython to save to the desktop of the computer that the Open MV is plugged into via the USB? Or, is there a way around having to restart the OpenMV to detect that a new file has been saved to the SD card?

Thanks,

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 15, 2018, 7:36am UTC](https://forums.openmv.io/t/saving-to-file/653/2 "2018-04-15T07:36:42Z")

</div>

Desktop OSes won’t rescan the flash drive unless plugged in. There’s no fix for this. The camera acting as a USB drive which can create files is not something handled by today’s desktop OS drivers.

You can however manually reset the OpenMV Cam in your script by issuing this command:

pyb.hard\_reset()

…

An alternative method is just to print out the bardcode value. Anything that opens the OpenMV Cam’s VCP UART will see the print data as text as whatever baud rate they open the OpenMV Cam serial port at. Note that you have to disconnect OpenMV IDE. But, it’s pretty easy to get your script working with print and be good… and then use another program to read the printed data.

---

<div class="post-metadata">

**Author:** ![aakoch](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/aakoch/32/28_2.png) [@aakoch](https://forums.openmv.io/u/aakoch)\
**Post date:** [April 21, 2018, 4:07am UTC](https://forums.openmv.io/t/saving-to-file/653/3 "2018-04-21T04:07:17Z")

</div>

What OS do you have? I am on a Mac with macOS High Sierra.

This is what I did. I wrote a program that prints the output:

```python
import pyb

while(True):
    print("Hello, World")
    pyb.delay(500)

```

I saved that to the camera then reset the camera.

I then found out the serial device name. You can do that through OpenMV IDE or by running

```python
ls /dev/cu.*

```

and finding the USB port.

I used the command

```python
screen /dev/cu.usbmodem1411 115200

```

to connect to my camera and verified it was printing to that serial port. (Use CTRL-A, then CTRL-\ to quit)

Next, I Google’d how to pipe a serial port and found this: [macos - Piping from serial port on Mac OS X - Super User](https://superuser.com/a/710840/141346)  
(There is also using an app called miniterm, but I didn’t try that.)

After some failed attempts, I was able to compile the code using XCode. I created a new project targeted for macOS and pasted the code into the main.cpp file and built the app. In the file viewer on the right I found the executable, found the location and copied it to my directory.

Then run the command

```python
./comm3 /dev/cu.usbmodem1411 115200 > serial_outfile.txt &

```

. (My project was named “comm3” hence the name of the executable.) I’m piping the output to serial\_output.txt and letting that run in the background.

I can then run

```python
tail -f serial_outfile.txt

```

to watch the file being written.

Hopefully this helps.

Adam
