Skip to content

Commit

Permalink
resolved trivial merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aleifer committed Jan 1, 2016
2 parents b93e977 + f5534ae commit 74bd279
Show file tree
Hide file tree
Showing 11 changed files with 535 additions and 181 deletions.
1 change: 1 addition & 0 deletions MyLibs/IllumWormProtocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
//OpenCV Headers
//#include <cxcore.h>
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
//#include <cv.h>

// Andy's Libraries
Expand Down
2 changes: 1 addition & 1 deletion MyLibs/Talk2FrameGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int PrepareFrameGrabberForAcquire(FrameGrabber* fg){

// Set the timout to be very short
printf("Setting acquisition timeout time.\n");
setAcquisitionTimeout(fg, 10); //in Aravis lab this was 4
setAcquisitionTimeout(fg, 100); //in Aravis lab this was 4


printf("Prepare frame grabber for acquire completed.");
Expand Down
45 changes: 36 additions & 9 deletions MyLibs/Talk2Stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ HANDLE InitializeUsbStage(){

/** Open the Serial Port **/
HANDLE hSerial;
hSerial = CreateFile("COM3", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
hSerial = CreateFile("COM4", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(hSerial==INVALID_HANDLE_VALUE){
if(GetLastError()==ERROR_FILE_NOT_FOUND){
//serial port does not exist.
Expand Down Expand Up @@ -156,6 +156,24 @@ HANDLE InitializeUsbStage(){

}


/*
*
* SendCommandToStage This is a wrapper of the Windows function WriteFile()
* See, e.g. https://msdn.microsoft.com/en-us/library/windows/desktop/aa365747%28v=vs.85%29.aspx
*
*/

BOOL SendCommandToStage(HANDLE hfile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped){
BOOL bErrorFlag;
bErrorFlag=WriteFile(hfile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
printf(" [SENT STAGE] `%s` \n",lpBuffer);
return bErrorFlag;

}



/*
If you don't clear some buffer and you are using the virtual com port driver, then
the stage stops responding to commands after around the 3300th command. By running this function
Expand All @@ -172,13 +190,14 @@ void clearStageBuffer(HANDLE s){

COMSTAT Status;

ClearCommError( s, &dwErrors, &Status);
ClearCommError( s, &dwErrors, &Status); // Windows function to clear a devices error flag
Length = Status.cbInQue; // get the rx data length in buffer
// Get data and put it in to iBuffer
// Get data and put it in to pText
DWORD nRead;
char * pText;
pText = (char *)malloc(sizeof(char)*(Length + 2));
ReadFile(s,pText, Length, &nRead,NULL);
printf(" [STAGE REPLY] `%s`\n",pText); // Display to console
free(pText);
return;

Expand All @@ -201,8 +220,8 @@ int spinStage(HANDLE s, int xspeed,int yspeed){


char* buff=(char*) malloc(sizeof(char)*1024);
sprintf(buff,"SPIN X=%d Y=%d\r",xspeed,yspeed);
bErrorFlag=WriteFile(s, buff, strlen(buff), &Length, NULL);
sprintf(buff,"SPIN X=%d Y=%d\r",-yspeed,-xspeed);
bErrorFlag=SendCommandToStage(s, buff, strlen(buff), &Length, NULL);
free(buff);

if (FALSE == bErrorFlag)
Expand All @@ -219,8 +238,16 @@ int spinStage(HANDLE s, int xspeed,int yspeed){

int haltStage(HANDLE s){
DWORD Length;
WriteFile(s, "HALT\r", strlen("HALT\r"), &Length, NULL);
BOOL bErrorFlag = FALSE;
printf("About to tell stage to halt, but first pausing execution for 5 ms\n");
_sleep(5);
bErrorFlag=SendCommandToStage(s, "HALT\r", strlen("HALT\r"), &Length, NULL);
if (FALSE == bErrorFlag){
printf("Failure: Unable to write to serial port.\n");
}
clearStageBuffer(s);
printf("Continuing to pause execution for 5 ms\n");
_sleep(5);
return 0;

}
Expand All @@ -229,7 +256,7 @@ int moveStageRel(HANDLE s, int xpos, int ypos){
DWORD Length;
char* buff=(char*) malloc(sizeof(char)*1024);
sprintf(buff,"MOVEI X=%d Y=%d\r",xpos,ypos);
WriteFile(s, buff, strlen(buff), &Length, NULL);
SendCommandToStage(s, buff, strlen(buff), &Length, NULL);
free(buff);
clearStageBuffer(s);
return 0;
Expand All @@ -238,15 +265,15 @@ int moveStageRel(HANDLE s, int xpos, int ypos){

int zeroStage(HANDLE s){
DWORD Length;
WriteFile(s, "HERE X=0 Y=0\r", strlen("HERE X=0 Y=0\r"), &Length, NULL);
SendCommandToStage(s, "HERE X=0 Y=0\r", strlen("HERE X=0 Y=0\r"), &Length, NULL);
clearStageBuffer(s);
return 0;

}

int centerStage(HANDLE s){
DWORD Length;
WriteFile(s, "CENTER X=30000 Y=30000\r", strlen("CENTER X=30000 Y=30000\r"), &Length, NULL);
SendCommandToStage(s, "CENTER X=30000 Y=30000\r", strlen("CENTER X=30000 Y=30000\r"), &Length, NULL);
printf("Centering stage.\n This takes a really really long time.\n");
printf("Hit enter when done. This will zero the stage.\n");
scanf("");
Expand Down
3 changes: 1 addition & 2 deletions MyLibs/TransformLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@


//OpenCV Headers
//#include <cxcore.h>
#include "opencv2/highgui/highgui_c.h"
//#include <cv.h>
#include "opencv2/imgproc/imgproc_c.h"

#include <stdio.h>
#include <stdbool.h>
Expand Down
Loading

0 comments on commit 74bd279

Please sign in to comment.