/*==============================================================================*/ /* Very basic terminal program fpr restoring CAN232 basic settings... */ /* */ /* DATE: 2004-May-19 18:20:12 */ /* */ /* Copyright (c) 2004 Attila Vass */ /* */ /* 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. */ /*==============================================================================*/ /* gcc acramr_calc_simple.c -o acramr_calc_simple */ #include #include int ID[256]; int numofids=0; int main(int argc, char *argv[]) { unsigned int a=1,c,b,d,ACR,AMR; if(argc>1) { while(a0;b--) { printf("%d",((ID[a]>>b)&1)); } printf("%d",((ID[a]>>b)&1)); } ACR=0;AMR=0; for(a=0;a<11;a++) { c=-1; for(b=0;b>a)&1); switch(c) { case -1 : // no data yet. c=d; break; case 1 : // so far 1s if(d==0) c=2; // this is going to be a don't care bit break; case 0 : if(d==1) c=2; break; } } if(c==2) AMR|=(1<0;b--) { printf("%d",((ACR>>b)&1)); } printf("%d",((ACR>>b)&1)); printf("\n AMR = 0x%04x ",AMR); for(b=11;b>0;b--) { printf("%d",((AMR>>b)&1)); } printf("%d",((AMR>>b)&1)); printf(" ( %d value[s] )",((AMR==0)?(1):(AMR))); ACR<<=5;AMR<<=5; AMR|=0xF; // don't care about data bytes printf("\n\nRegister Values = ACR=%04x AMR=%04x\n\n",ACR,AMR);fflush(stdout); return(0); } /* M07207960 & m00400000 => lets through only 3B and 3CB M07207960 & m00000040 => lets through only 3C9 and 3CB M07207960 & m00430003 => lets trough 39, 3B, 3CB M79600720 & m00000040 => lets through only 39 and 3B M79600720 & m00400000 => lets through only 39 */