|
|
@ -53,9 +53,9 @@ int Receiver::initSerial(){
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::readCdcData(uint8_t (*character)[50]) {
|
|
|
|
int Receiver::readCdcData(uint8_t (*character)[CDC_FRAME_SIZE]) {
|
|
|
|
memset(*character, 0x00, 50);
|
|
|
|
memset(*character, 0x00, CDC_FRAME_SIZE);
|
|
|
|
int bytesRead = read(cdcFile, character, 50);
|
|
|
|
int bytesRead = read(cdcFile, character, CDC_FRAME_SIZE);
|
|
|
|
if (bytesRead == -1) {
|
|
|
|
if (bytesRead == -1) {
|
|
|
|
std::cerr << "Error in read" << std::endl;
|
|
|
|
std::cerr << "Error in read" << std::endl;
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
@ -65,21 +65,24 @@ int Receiver::readCdcData(uint8_t (*character)[50]) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* PRINT WHAT IS RECEIVED
|
|
|
|
#if 0 // PRINT WHAT IS RECEIVED
|
|
|
|
for(int i = 0; i<50; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
for(int i = 0; i<CDC_FRAME_SIZE; i++)
|
|
|
|
printHex((*character)[i]);
|
|
|
|
{
|
|
|
|
//std::cout << unsigned(character[i]);
|
|
|
|
printHex((*character)[i]);
|
|
|
|
std::cout << " ";
|
|
|
|
//std::cout << unsigned(character[i]);
|
|
|
|
}
|
|
|
|
std::cout << " ";
|
|
|
|
std::cout << std::endl << std::endl;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
std::cout << std::endl << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::simulateRead(unsigned char (*character)[50]){
|
|
|
|
int Receiver::simulateRead(unsigned char (*character)[CDC_FRAME_SIZE]){
|
|
|
|
memset(*character, 0x00, 50);
|
|
|
|
memset(*character, 0x00, CDC_FRAME_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
int firstLen = (int)t1.size();
|
|
|
|
int firstLen = (int)t1.size();
|
|
|
|
int secondLen = (int)t2.size();
|
|
|
|
int secondLen = (int)t2.size();
|
|
|
@ -93,7 +96,7 @@ int Receiver::simulateRead(unsigned char (*character)[50]){
|
|
|
|
vecId = 2;
|
|
|
|
vecId = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<50; i++){
|
|
|
|
for(int i=0; i<CDC_FRAME_SIZE; i++){
|
|
|
|
if(vecId == 1){
|
|
|
|
if(vecId == 1){
|
|
|
|
if(simulateIdx > firstLen){
|
|
|
|
if(simulateIdx > firstLen){
|
|
|
|
(*character)[i] = 0x00;
|
|
|
|
(*character)[i] = 0x00;
|
|
|
@ -118,7 +121,7 @@ int Receiver::simulateRead(unsigned char (*character)[50]){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::fillBuffer(){
|
|
|
|
int Receiver::fillBuffer(){
|
|
|
|
unsigned char character[50];
|
|
|
|
unsigned char character[CDC_FRAME_SIZE];
|
|
|
|
std::vector<uint8_t> tempVec{};
|
|
|
|
std::vector<uint8_t> tempVec{};
|
|
|
|
|
|
|
|
|
|
|
|
Receiver::readCdcData(&character);
|
|
|
|
Receiver::readCdcData(&character);
|
|
|
@ -183,6 +186,7 @@ void Receiver::bufferToDisplay(){
|
|
|
|
currentBufferIndexMutex.lock();
|
|
|
|
currentBufferIndexMutex.lock();
|
|
|
|
int buffIdx = currentBufferIndex;
|
|
|
|
int buffIdx = currentBufferIndex;
|
|
|
|
currentBufferIndexMutex.unlock();
|
|
|
|
currentBufferIndexMutex.unlock();
|
|
|
|
|
|
|
|
std::cout << buffIdx << std::endl;
|
|
|
|
switch(buffIdx){
|
|
|
|
switch(buffIdx){
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
dis->vectorToTexture(&buffer1);
|
|
|
|
dis->vectorToTexture(&buffer1);
|
|
|
@ -205,15 +209,15 @@ void Receiver::initTextures(){
|
|
|
|
dis->vectorToTexture(&buffer_initial);
|
|
|
|
dis->vectorToTexture(&buffer_initial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::findSequence(unsigned char (*str)[50], unsigned char ch1, unsigned char ch2){
|
|
|
|
int Receiver::findSequence(unsigned char (*str)[CDC_FRAME_SIZE], unsigned char ch1, unsigned char ch2){
|
|
|
|
if(sequenceEndedFF){
|
|
|
|
if(sequenceEndedFF){
|
|
|
|
sequenceEndedFF = 0;
|
|
|
|
sequenceEndedFF = 0;
|
|
|
|
if((*str)[0] == ch2){
|
|
|
|
if((*str)[0] == ch2){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i=0; i<50; i++){
|
|
|
|
for(int i=0; i<CDC_FRAME_SIZE; i++){
|
|
|
|
if((*str)[i] == ch1 && i < 50){
|
|
|
|
if((*str)[i] == ch1 && i < CDC_FRAME_SIZE){
|
|
|
|
if((*str)[i+1] == ch2){
|
|
|
|
if((*str)[i+1] == ch2){
|
|
|
|
return i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -225,12 +229,12 @@ int Receiver::findSequence(unsigned char (*str)[50], unsigned char ch1, unsigned
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::findStart(unsigned char (*str)[50]){
|
|
|
|
int Receiver::findStart(unsigned char (*str)[CDC_FRAME_SIZE]){
|
|
|
|
int res = findSequence(str, 0xFF, 0xD8);
|
|
|
|
int res = findSequence(str, 0xFF, 0xD8);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Receiver::findEnd(unsigned char (*str)[50]){
|
|
|
|
int Receiver::findEnd(unsigned char (*str)[CDC_FRAME_SIZE]){
|
|
|
|
int res = findSequence(str, 0xFF, 0xD9);
|
|
|
|
int res = findSequence(str, 0xFF, 0xD9);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|