mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
grovescam: Initial implementation
This module was developed on the Grove Serial Camera. It connects to the UART and runs at 115200 baud. It was developed based on the Seeed Studio Arduino sketch, as there appears to be no protocol documentation available. Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
89c9239798
commit
fcf2b9c6aa
@ -121,6 +121,7 @@ add_executable (hm11-example hm11.cxx)
|
||||
add_executable (ht9170-example ht9170.cxx)
|
||||
add_executable (h3lis331dl-example h3lis331dl.cxx)
|
||||
add_executable (ad8232-example ad8232.cxx)
|
||||
add_executable (grovescam-example grovescam.cxx)
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||
@ -220,6 +221,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/hm11)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ht9170)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/h3lis331dl)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ad8232)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovescam)
|
||||
|
||||
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
@ -342,3 +344,4 @@ target_link_libraries (hm11-example hm11 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
77
examples/c++/grovescam.cxx
Normal file
77
examples/c++/grovescam.cxx
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "grovescam.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a Grove Serial Camera on UART 0
|
||||
upm::GROVESCAM* camera = new upm::GROVESCAM(0);
|
||||
|
||||
// make sure port is initialized properly. 115200 baud is the default.
|
||||
if (!camera->setupTty())
|
||||
{
|
||||
cerr << "Failed to setup tty port parameters" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (camera->init())
|
||||
cout << "Initialized..." << endl;
|
||||
else
|
||||
cout << "init() failed" << endl;
|
||||
|
||||
if (camera->preCapture())
|
||||
cout << "preCapture succeeded..." << endl;
|
||||
else
|
||||
cout << "preCapture failed." << endl;
|
||||
|
||||
if (camera->doCapture())
|
||||
cout << "doCapture succeeded..." << endl;
|
||||
else
|
||||
cout << "doCapture failed." << endl;
|
||||
|
||||
cout << "Image size is " << camera->getImageSize() << " bytes" << endl;
|
||||
|
||||
if (camera->getImageSize() > 0)
|
||||
{
|
||||
cout << "Storing image.jpg..." << endl;
|
||||
if (camera->storeImage("image.jpg"))
|
||||
cout << "storeImage succeeded..." << endl;
|
||||
else
|
||||
cout << "storeImage failed." << endl;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
delete camera;
|
||||
return 0;
|
||||
}
|
72
examples/javascript/grovescam.js
Normal file
72
examples/javascript/grovescam.js
Normal file
@ -0,0 +1,72 @@
|
||||
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||
/*jshint unused:true */
|
||||
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var cameraObj = require('jsupm_grovescam');
|
||||
|
||||
// Instantiate a Grove Serial Camera on UART 0
|
||||
var camera = new cameraObj.GROVESCAM(0);
|
||||
|
||||
// make sure port is initialized properly. 115200 baud is the default.
|
||||
if (!camera.setupTty())
|
||||
{
|
||||
console.log("Failed to setup tty port parameters");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (camera.init())
|
||||
console.log("Initialized...");
|
||||
else
|
||||
console.log("init() failed");
|
||||
|
||||
if (camera.preCapture())
|
||||
console.log("preCapture succeeded...");
|
||||
else
|
||||
console.log("preCapture failed.");
|
||||
|
||||
if (camera.doCapture())
|
||||
console.log("doCapture succeeded...");
|
||||
else
|
||||
console.log("doCapture failed.");
|
||||
|
||||
console.log("Image size is " + camera.getImageSize() + " bytes");
|
||||
|
||||
if (camera.getImageSize() > 0)
|
||||
{
|
||||
console.log("Storing image.jpg...");
|
||||
if (camera.storeImage("image.jpg"))
|
||||
console.log("storeImage succeeded...");
|
||||
else
|
||||
console.log("storeImage failed.");
|
||||
}
|
||||
|
||||
|
||||
camera = null;
|
||||
cameraObj.cleanUp();
|
||||
cameraObj = null;
|
||||
console.log("Exiting.");
|
||||
process.exit(0);
|
||||
|
61
examples/python/grovescam.py
Normal file
61
examples/python/grovescam.py
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import sys
|
||||
import pyupm_grovescam as upmGrovescam
|
||||
|
||||
# Instantiate a Grove Serial Camera on UART 0
|
||||
camera = upmGrovescam.GROVESCAM(0)
|
||||
|
||||
# make sure port is initialized properly. 115200 baud is the default.
|
||||
if (not camera.setupTty()):
|
||||
print "Failed to setup tty port parameters"
|
||||
sys.exit(1)
|
||||
|
||||
if (camera.init()):
|
||||
print "Initialized..."
|
||||
else:
|
||||
print "init() failed"
|
||||
|
||||
if (camera.preCapture()):
|
||||
print "preCapture succeeded..."
|
||||
else:
|
||||
print "preCapture failed."
|
||||
|
||||
if (camera.doCapture()):
|
||||
print "doCapture succeeded..."
|
||||
else:
|
||||
print "doCapture failed."
|
||||
|
||||
print "Image size is", camera.getImageSize(), "bytes"
|
||||
|
||||
if (camera.getImageSize() > 0):
|
||||
print "Storing image.jpg..."
|
||||
if (camera.storeImage("image.jpg")):
|
||||
print "storeImage succeeded..."
|
||||
else:
|
||||
print "storeImage failed."
|
||||
|
||||
print "Exiting."
|
||||
sys.exit(0)
|
Reference in New Issue
Block a user