Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I have a function which makes use of structures and some global variables. Briefly the function receives data from a comm port, processes it and sends a response. I would like to implement this function twice, i.e one listens to comm1 and responds through comm1, and the other listens on comm2 and responds on comm2. I pass two items to the function (rcx_buffer and commport to use). The problem is i have a structure for the function that stores certain status/values of the previous received frame, what i dont want is one call to the function (for say commport 1) to override globals that are required by another call to the function (for commport 2). What is the best way to acheive this or is this beyond C.
I could implement the function with 2 names and create a whole seperate list of globals, but this is messy.
I beleive i could change the globals to exist only in the scope of the function, would this work? But this wont easily work with the structure to the code i have created so far.
Any suggestions appreciated.
0 · ·