bool UP3D_SetPrintJobInfo( uint8_t progID, uint8_t x, uint32_t y ) { if( progID>9 ) return false; uint8_t UP3D_CMD_63_X_Y[7] = { 0x63, progID, x, (y>>0)&0xFF, (y>>8)&0xFF, (y>>16)&0xFF, (y>>24)&0xFF }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_63_X_Y, sizeof(UP3D_CMD_63_X_Y) ) != sizeof(UP3D_CMD_63_X_Y)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; } bool UP3D_InsertRomProgram( uint8_t prog ) { uint8_t UP3D_CMD_4C_X[] = { 0x4C, '0'+prog }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_4C_X, sizeof(UP3D_CMD_4C_X) ) != sizeof(UP3D_CMD_4C_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) || (1 != resp[0]) ) return false; return true; }
bool UP3D_GetPrinterInfo(TT_tagPrinterInfoHeader *pihdr, TT_tagPrinterInfoName *piname, TT_tagPrinterInfoData *pidata, TT_tagPrinterInfoSet pisets[8]) { static const uint8_t UP3D_CMD_52[] = { 0x52, 0x00 }; //GetPrinterInfo uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_52, sizeof(UP3D_CMD_52) ) != sizeof(UP3D_CMD_52)) ) return false; if( (1 != UP3DCOMM_Read( resp, 1 )) || (7 != resp[0]) ) return false; if( (sizeof(TT_tagPrinterInfoHeader) != UP3DCOMM_Read( (uint8_t*)pihdr, sizeof(TT_tagPrinterInfoHeader) )) || (sizeof(TT_tagPrinterInfoName ) != UP3DCOMM_Read( (uint8_t*)piname, sizeof(TT_tagPrinterInfoName) )) || (sizeof(TT_tagPrinterInfoData) != UP3DCOMM_Read( (uint8_t*)pidata, sizeof(TT_tagPrinterInfoData) )) ) return false; if( pidata->u32_NumSets>8 ) return false; uint32_t s; for( s=0; s<pidata->u32_NumSets; s++ ) { if( (16 != UP3DCOMM_Read( (uint8_t*)(&pisets[s])+ 0, 16 )) || (60 != UP3DCOMM_Read( (uint8_t*)(&pisets[s])+16, 60 )) || (60 != UP3DCOMM_Read( (uint8_t*)(&pisets[s])+76, 60 )) ) return false; } if( (1 != UP3DCOMM_Read( resp, 1 )) || (6 != resp[0]) ) return false; return true; }
bool UP3D_WriteBlocks( const UP3D_BLK *data, uint8_t blocks ) { uint8_t send[2048]; for( ;blocks>0; ) { uint8_t b = blocks; if( _up3d_connected_fw_version<330 ) if (b > 3) b = 3; //older firmware versions support max 64 bytes (3 blocks) per write only if( b>72 ) b = 72; //limit to max. 2048 bytes per logical packet uint32_t fblocks= UP3D_GetFreeBlocks(); if( b>fblocks ) b = fblocks; if( b>0 ) { uint8_t UP3D_CMD_2F_X[] = { 0x2F, b }; memcpy( &send[0], UP3D_CMD_2F_X, 2 ); memcpy( &send[2], data, 20*b ); //data++; if( UP3DCOMM_Write( send, 2+20*b ) != 2+20*b ) return false; blocks -= b; data += b; } else usleep( 100000 ); } return true; }
unsigned int UP3D_IsPrinterResponsive() { static const uint8_t UP3D_CMD_1[] = { 0x01, 0x00 }; //GetFwVersion uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_1, sizeof(UP3D_CMD_1) ) != sizeof(UP3D_CMD_1)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return false; <<<<<<< HEAD:UP3DTOOLS/up3d.c
bool UP3D_Execute() { static const uint8_t UP3D_CMD_58[] = { 0x58 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_58, sizeof(UP3D_CMD_58) ) != sizeof(UP3D_CMD_58)) || (0 == UP3DCOMM_Read( resp, sizeof(resp) )) /*|| (6 != resp[0])*/ ) //returns "Exe Count: 0" 06 return false; return true; }
bool UP3D_IsPrinterResponsive() { static const uint8_t UP3D_CMD_1[] = { 0x01, 0x00 }; //GetFwVersion ? uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_1, sizeof(UP3D_CMD_1) ) != sizeof(UP3D_CMD_1)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return false; return true; }
uint32_t UP3D_GetParameter(uint8_t param) { uint8_t UP3D_CMD_76_X[] = { 0x76, param }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_76_X, sizeof(UP3D_CMD_76_X) ) != sizeof(UP3D_CMD_76_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return 0; return le32toh( *((uint32_t*)resp) ); }
bool UP3D_SendRandom() { uint8_t UP3D_CMD_2B_RRR[9] = { 0x2B, 0xCA,0xFE,0x00,0x00,0x00,0x00,0x12,0x34 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_2B_RRR, sizeof(UP3D_CMD_2B_RRR) ) != sizeof(UP3D_CMD_2B_RRR)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; }
bool UP3D_BeginWrite() { static const uint8_t UP3D_CMD_63[] = { 0x63 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_63, sizeof(UP3D_CMD_63) ) != sizeof(UP3D_CMD_63)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; }
bool UP3D_ClearProgramBuf() { static const uint8_t UP3D_CMD_43[] = { 0x43 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_43, sizeof(UP3D_CMD_43) ) != sizeof(UP3D_CMD_43)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; }
uint32_t UP3D_GetFreeBlocks() { static const uint8_t UP3D_CMD_46[] = { 0x46 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_46, sizeof(UP3D_CMD_46) ) != sizeof(UP3D_CMD_46)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return 0; return le32toh( *((uint32_t*)resp) ); }
bool UP3D_SetParameter(uint8_t param, uint32_t value) { uint8_t UP3D_CMD_56_X_Y[6] = { 0x56, param, 0x00,0x00,0x00,0x00 }; memcpy( &UP3D_CMD_56_X_Y[2], &value, sizeof(value) ); uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_56_X_Y, sizeof(UP3D_CMD_56_X_Y) ) != sizeof(UP3D_CMD_56_X_Y)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; }
bool UP3D_GetSystemVar(uint8_t param, int32_t *var) { uint8_t UP3D_CMD_76_X[] = { 0x76, param }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_76_X, sizeof(UP3D_CMD_76_X) ) != sizeof(UP3D_CMD_76_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return false; *var = le32toh( *((uint32_t*)resp) ); return true; }
bool UP3D_IsPrinterResponsive() { static const uint8_t UP3D_CMD_1[] = { 0x01, 0x00 }; //GetFwVersion uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_1, sizeof(UP3D_CMD_1) ) != sizeof(UP3D_CMD_1)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return false; _up3d_connected_fw_version = le32toh(*((uint32_t*)resp)); return true; }
uint32_t UP3D_GetParameter(uint8_t param) { uint8_t UP3D_CMD_76_X[] = { 0x76, param }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_76_X, sizeof(UP3D_CMD_76_X) ) != sizeof(UP3D_CMD_76_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return 0; uint32_t r; memcpy( &r, resp, sizeof(r) ); return r; }
uint32_t UP3D_GetFreeBlocks() { static const uint8_t UP3D_CMD_46[] = { 0x46 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_46, sizeof(UP3D_CMD_46) ) != sizeof(UP3D_CMD_46)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return 0; uint32_t r; memcpy( &r, resp, sizeof(r) ); return r; }
int32_t UP3D_GetAxisPosition(int axis) { if( (axis<1) || (axis>4) ) return -1; uint8_t UP3D_CMD_70_X[] = { 0x70, '0'+axis-1 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_70_X, sizeof(UP3D_CMD_70_X) ) != sizeof(UP3D_CMD_70_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) ) return 0; return le32toh( *((uint32_t*)resp) ); }
bool UP3D_InsertRomProgram( uint8_t prog ) { uint8_t UP3D_CMD_4C_X[] = { 0x4C, '0'+prog }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_4C_X, sizeof(UP3D_CMD_4C_X) ) != sizeof(UP3D_CMD_4C_X)) || (5 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[4]) || (1 != resp[0]) ) return false; return true; }
bool UP3D_SetProgramID( uint8_t progID, bool enableWrite ) { if( progID>9 ) return false; uint8_t UP3D_CMD_6C_X_Y[3] = { 0x6C, progID, enableWrite?0x01:0x00 }; uint8_t resp[2048]; if( (UP3DCOMM_Write( UP3D_CMD_6C_X_Y, sizeof(UP3D_CMD_6C_X_Y) ) != sizeof(UP3D_CMD_6C_X_Y)) || (1 != UP3DCOMM_Read( resp, sizeof(resp) )) || (6 != resp[0]) ) return false; return true; }
bool UP3D_WriteBlocks( const UP3D_BLK *data, uint8_t blocks ) { uint8_t send[2048]; uint32_t out = 0; for( ;blocks>0; ) { uint8_t b = blocks; if( b>3 ) b = 3; for( ;out+2+20*b>2048; b--) ; if( b<3 ) { uint8_t UP3D_CMD_2F_X[] = { 0x2F, blocks }; memcpy( &send[out], UP3D_CMD_2F_X, 2 ); memcpy( &send[out+2], data, 20*blocks ); data++; out+=2+20*blocks; } else { static const uint8_t UP3D_CMD_00_00[] = { 0x00, 0x00 }; static const uint8_t UP3D_CMD_2F_03[] = { 0x2F, 0x03 }; memcpy( &send[out], UP3D_CMD_2F_03, 2 ); memcpy( &send[out+2], data, 20*3 ); data +=3; out+=2+20*3; if( ((blocks-b)>0) && (out<=2048-22) ) { memcpy( &send[out+2+20*3], UP3D_CMD_00_00, 2 ); out+=2; } } blocks -= b; if( !blocks || (out>2048-22) ) { if( UP3DCOMM_Write( send, out ) != out ) return false; out = 0; } } return true; }