On Fri, 18 Jan 2013, khouryelie wrote:
>
>
> --- In "khouryelie" wrote:
> >
> >
> > thanks everyone but i am starting to think its not my code that's wrong
> > it's just the cable connections
> >
> > i am configuring with my code port COM2 to 485 FULL DUPLEX
> > but i am using a null modem cable THE SAME I USED TO TEST ports 232 and
> > connecting that modem cable to a converter cable from 485 -> 232 then
> > reading with minicom Through a 232 TO USB
> >
> > I think that sending from 485 port to a null modem( that was used with
> > success with 232 ) is the mistake
> >
> > ANYONE KNOW IF I should get A 485 null modem cable ?
> > IS THERE ANY DIFFRENCE between NULL MODEM CABLES ? SOME FOR 232 QND OTHES
> > FOR 485 FULL DUPLEX ?
> >
>
> scratch that i am trying with loopback testing and its not working so i added
> an if tester into my CODE:
>
> #include<unistd.h>
> #include<sys/types.h>
> #include<sys/mman.h>
> #include<stdio.h>
> #include<fcntl.h>
> #include<assert.h>
>
>
> int main(void)
> {
> int fd;
> volatile unsigned char *base,*comp;
>
> fd = open("/dev/mem", O_RDWR | O_SYNC);
> if (fd == -1)
> {
> perror("Error opening file for writing");
> }
>
> base = (unsigned char
> *)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x22C00000);
> if (base == MAP_FAILED)
> {
> perror ("mmap");
> return 1;
> }
> comp = (unsigned char
> *)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x22C00000);
>
> *base = 0x01;
> if(*base==*comp)
> printf("ERROR \n");
>
> close(fd);
> }
>
> qnd actually it does return ERROR meaning the value didnt change so i guess
> my code is wrong and i am not correctly going from 232 to 485 full duplex
>
Why don't you just slow down and think about the code slowly and locically.
What are you testing with the final "if"? You have 2 pointers to the same
memory location and testing if the values returned are equal - then
declaring some sort of error - I think your logic is wrong.
This code is actually setting full duplex rs485 mode.
I do not understand your set up from your description, so cannot help.
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|