Add in JVS pass through
This commit is contained in:
parent
fb8b25bc86
commit
8cc876554a
@ -205,22 +205,18 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
}
|
}
|
||||||
else if (jvsFileDescriptor >= 0)
|
else if (jvsFileDescriptor >= 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
write(jvsFileDescriptor, inputBuffer, jvsCommand.srcSize);
|
write(jvsFileDescriptor, inputBuffer, jvsCommand.srcSize);
|
||||||
for (int i = 0; i < jvsCommand.srcSize; i++)
|
|
||||||
printf("%X ", inputBuffer[i]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < jvsCommand.srcSize; i++)
|
for (int i = 0; i < jvsCommand.srcSize; i++)
|
||||||
{
|
{
|
||||||
if (inputBuffer[i] == 0xF0)
|
if (inputBuffer[i] == 0xF0)
|
||||||
{
|
{
|
||||||
printf("SENSE LINE 3\n");
|
|
||||||
setSenseLine(3);
|
setSenseLine(3);
|
||||||
}
|
}
|
||||||
else if (inputBuffer[i] == 0xF1)
|
else if (inputBuffer[i] == 0xF1)
|
||||||
{
|
{
|
||||||
setSenseLine(1);
|
setSenseLine(1);
|
||||||
printf("SENSE LINE 1\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,12 +266,13 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
}
|
}
|
||||||
else if (jvsFileDescriptor >= 0)
|
else if (jvsFileDescriptor >= 0)
|
||||||
{
|
{
|
||||||
int count = read(jvsFileDescriptor, &sharedMemory[jvsCommand.destAddress], 255);
|
int count = readBytes(jvsFileDescriptor, &sharedMemory[jvsCommand.destAddress], 255);
|
||||||
|
|
||||||
|
if (count == -1)
|
||||||
|
count = 0;
|
||||||
|
|
||||||
_data[2] = jvsCommand.destAddress;
|
_data[2] = jvsCommand.destAddress;
|
||||||
_data[3] = count;
|
_data[3] = count;
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
printf("%X ", sharedMemory[jvsCommand.destAddress + i]);
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
|
|
||||||
|
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
|
#define TIMEOUT_SELECT 200
|
||||||
|
|
||||||
int setSerialAttributes(int fd, int myBaud)
|
int setSerialAttributes(int fd, int myBaud)
|
||||||
{
|
{
|
||||||
struct termios options;
|
struct termios options;
|
||||||
@ -38,8 +39,8 @@ int setSerialAttributes(int fd, int myBaud)
|
|||||||
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||||
options.c_oflag &= ~OPOST;
|
options.c_oflag &= ~OPOST;
|
||||||
|
|
||||||
options.c_cc[VMIN] = 10;
|
options.c_cc[VMIN] = 0;
|
||||||
options.c_cc[VTIME] = 10; // One seconds (10 deciseconds)
|
options.c_cc[VTIME] = 0; // One seconds (10 deciseconds)
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &options);
|
tcsetattr(fd, TCSANOW, &options);
|
||||||
|
|
||||||
@ -64,3 +65,25 @@ int setSerialAttributes(int fd, int myBaud)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBytes(int fd, unsigned char *buffer, int amount)
|
||||||
|
{
|
||||||
|
fd_set fd_serial;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
FD_ZERO(&fd_serial);
|
||||||
|
FD_SET(fd, &fd_serial);
|
||||||
|
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = TIMEOUT_SELECT * 1000;
|
||||||
|
|
||||||
|
int filesReadyToRead = select(fd + 1, &fd_serial, NULL, NULL, &tv);
|
||||||
|
|
||||||
|
if (filesReadyToRead < 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!FD_ISSET(fd, &fd_serial))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return read(fd, buffer, amount);
|
||||||
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
|
||||||
int setSerialAttributes(int fd, int myBaud);
|
int setSerialAttributes(int fd, int myBaud);
|
||||||
|
int readBytes(int fd, unsigned char *buffer, int amount);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user